He is saying that the Collections class tries to do a lot of different things that aren't necessarily related to each other. "Catch-all" is not a technical term, it is just an English term to describe the way the class was designed.
Now, for you post. I hope that you have learned about loops; if not, this might not make sense. But try to look around at tutorials and see if you can understand it.
Code:
Scanner input = new Scanner(System.in);
String[] array = new String[5];
for (int i = 0; i < 5 && input.hasNextLine(); i++) {
String line = input.nextLine();
String reversed = reverse(line);
array[i] = reversed;
}
This works by using a "for loop" to get another line from the scanner 5 times. Then, for each line it finds, it reverses it and places the reversed version in an array named "array".
It's pretty easy to extend this so that it will read every line in the input scanner.
Code:
Scanner input = new Scanner(System.in);
ArrayList<String> list = new ArrayList<String>();
while (input.hasNextLine()) {
String line = input.nextLine();
String reversed = reverse(line);
list.add(reversed);
}
This is similar to the above example, except instead of being limited to 5 lines, it will read in as many lines as it can.
Bookmarks