Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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 to answer this question.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...