Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Java by (120 points)

class Book

{

    //// FIELDS ////

    private String longestWord;

    private int wordCount;

    private ArrayList<String> wordList = new ArrayList<String>();

    /* Declare fields for the word list, the word count, and the longest word.*/

    

    ////// CONSTRUCTOR //////

    //@param f -- the file object

    public Book(File f)

    {

        wordList = readBook(f);

        wordCount = countWords(wordList);

        longestWord = findLongestWord(wordList); 

    }

public static String findLongestWord(ArrayList<String> b)

    {

        try 

        {

            String longest = b.get(0);

        }

        catch (Exception f)

        {

            System.out.println("The longest word eludes me.");

        }

        return longestWord; Problem is HERE

    }

Please log in or register to answer this question.

Browse Categories

...