Building an Array


Added on  2019-09-16

1 Pages277 Words217 Views
Problems:1. Write a method called arrayBuilder that takes an integer parameter (length), returns an 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 returned Pass the array and a file name to the writeArray method Pass the file name to the readFile method In the main method loop through the returned ArrayList to print its contents to the command line
Building an Array_1

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents

Vowel Histogram Generator

CIS120 Exam2: Grade Calculator

Vehicle Warranty and Person Class

Person Class Implementation

Programming Paradigms and Scopes