For the sort by last name output, does the name needs to be "firstname lastname"? Because, I swapped the 2 and sorted it. But not sure if the output needs to be reversed for each name.
Also when I compile my program, I got a note saying the program uses unchecked or unafe operations, recompile with -Xlint:unchecked for details. When I do recompile, it warns about my ArrayList.add and Collections.sort: ArrayList.add(<some string>) and Collection.sort(<some arraylist>). According to the API, ArrayList.add(Element) and Collections.sort(List<T>).
This makes me wonder isn't an arraylist a list and can string be element? If not to either, how to ensure it is a list or element respectively? casting? Any help on this is appreciated. Thanks
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
10
posted
0
For the sort by last name output, does the name needs to be "firstname lastname"? Because, I swapped the 2 and sorted it. But not sure if the output needs to be reversed for each name.
The output should be "firstname lastname". You should not change the list or create a new list to get the correct output.
Also when I compile my program, I got a note saying the program uses unchecked or unafe operations, recompile with -Xlint:unchecked for details. When I do recompile, it warns about my ArrayList.add and Collections.sort: ArrayList.add(<some string>) and Collection.sort(<some arraylist>). According to the API, ArrayList.add(Element) and Collections.sort(List<T>).
This makes me wonder isn't an arraylist a list and can string be element? If not to either, how to ensure it is a list or element respectively? casting?
If you only got warnings, but were able to compile and run the class, you don't need to worry. The warnings were added in jdk-5 for jdk-5-specific syntax.
JavaBeginnersFaq "Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.