This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
I was just working with an ArrayList in a project I'm trying to complete, and found that ArrayList itself doesn't have a .sort() method. In the course of asking around, I found that Collections.sort(myArrayList) will work, but I have another issue I'd like some help with.
How the(#&$ would I have been able to figure that out from reading the API documentation? I've gone through the interfaces, subclasses, superclasses, etc of ArrayList and nowhere do I find a reference to the static methods available in Collections. Someone want to donate a clue to me? I'd really rather be able to look up answers myself
It's hard to get the big picture just by looking at the methods of a class. One clue might have been the link at the bottom of the class description "This class is a member of the Java Collections Framework", which will lead you to another page describing the collections package. Once there, either the Overview or the Tutorial page would have talked about sorting. But rest assured that I didn't know this either, until I looked it up just now. [ March 15, 2006: Message edited by: Ulf Dittmer ]
The Java Almanac is an invaluable resource for the beginning programmer. 1000's of searchable examples covering the whole API. For example, your plight with sorting. Type "sort" into the box marked "Search for Code Examples" and the second hit is what you were looking for. When that fails, there's always Google and JavaRanch.