Menu

Question Involves Class Named Textfile Represents Text File Public Class Textfile Private Q43818795

This question involves a class named TextFile that represents atext file.
public class TextFile
{

private String fileName;

private ArrayList<String> words;

// constructors not shown

// postcondition: returns the number of bytes in this file

public int fileSize()

{

}

// precondition: 0 <= index < words.size()

// postcondition: removes numWords words from the wordsArrayList beginning at

// index.

publ ic void deleteWords(int index, int numWords)

{

}

// precondition: 0 <= index <= words.size()

// postcondition: adds elements from newWords array to wordsArrayList beginning

// at index.

public void addWords(int index, String[] newWords)

{

}
// other methods not shown
}
Complete the addWords() method. This method adds the elements fromthe newWords array to the words ArrayList, beginning at the givenindex. The index parameter is assumed to be greater than or equalto 0, and less than or equal to the size of the ArrayList, so thatits value is either a valid index into the ArrayList, or itindicates that the words are to be added to the end of theArrayList.

// precondition: 0 <= index <= words.size()
// postcondition: adds elements from newWords array to wordsArrayList beginning
// at index.
public void addWords(int index, St ring[] newWords)
{

}

Please answer in Java

Expert Answer


Answer to This question involves a class named TextFile that represents a text file. public class TextFile { private String fileNa…

OR