Problems:. 1. Write a method called arrayBuilder that t

Added on - 16 Sep 2019

  • 1

    Pages

  • 277

    Words

  • 217

    Views

  • 0

    Downloads

Trusted by +2 million users,
1000+ happy students everyday
Showing pages 1 to 1 of 1 pages
Problems:1. Write a method called arrayBuilder that takes an integer parameter (length), returnsan array of Strings,and is declared to throw an Exception. If the parameter passed is a negative value,throwan Exception. Otherwise, build and return an array of Strings with size based onthe parameter passed. (2 points)2. Write a method called writeArray that takes two parameters: an array of Strings anda String (fileName), and returns nothing. Write the array of Strings to a text filenamed using the fileName parameter. Make sure to catch any Exception thatmight be thrown. (3 points)3. Write a method called readFile that takes a String parameter (fileName) andreturns an ArrayList of Strings. The method reads the text file (fileName) andpopulates the ArrayList with an element for each line in the file. The returns thepopulated ArrayList. Make sure to catch any Exception thatmight be thrown. (3 points)4. Call each of the methods above from the main method.The pseudocode for the main method will be as given below.Make sure to catch any Exception thatmight be thrown. (2 points)Call arrayBuilder passing the size of the array that you want returnedPass the array and a file name to the writeArray methodPass the file name to the readFile methodIn the main method loop through the returned ArrayList to printits contents to the command line
desklib-logo
You’re reading a preview
Preview Documents

To View Complete Document

Click the button to download
Subscribe to our plans

Download This Document