Question: having a few problems with the JAVA code below mainly with the lines su=new SentenceUtils(sentence); slist.add(index, su); slist.get(i).report(); not sure how to fix what i

having a few problems with the JAVA code below mainly with the lines

su=new SentenceUtils(sentence);

slist.add(index, su);

slist.get(i).report();

not sure how to fix what i need to make it work, the program should take a text file and scan the file so that it can be used in another class.

import java.io.File;

import java.io.FileNotFoundException;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

public class SentenceUtilsTest {

private static List slist = new ArrayList();

public static void main(String[] args) {

System.out.println(" ----------------------------------------------------------------- ");

System.out.println("COP3330 Sentence Utility Program by ");

System.out.println(" Input file name: "+args[0]);

try {

File file=new File(args[0]);

Scanner scanner = new Scanner(file);

int index=0;

while(scanner.hasNext()) {

String sentence=scanner.nextLine();

if(sentence.length()!=0) {

su=new SentenceUtils(sentence);

slist.add(index, su);

index++;

}

}

scanner.close();

System.out.println("Number of sentences: "+index);

for(int i=0;i

System.out.println(" Sentence "+i+" >");

slist.get(i).report();

System.out.println();

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!