File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Reading the API (aka RTFM) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Reading the API (aka RTFM)" Watch "Reading the API (aka RTFM)" New topic

Reading the API (aka RTFM)

Zach Burnham

Joined: Feb 15, 2006
Posts: 16
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
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42959
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 ]
Joe Ess

Joined: Oct 29, 2001
Posts: 9168

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.

[How To Ask Questions On JavaRanch]
Zach Burnham

Joined: Feb 15, 2006
Posts: 16
Thanks for the info. I'd been to the almanac before but wasn't making the connection today... java makes my brain tired
I agree. Here's the link:
subject: Reading the API (aka RTFM)
It's not a secret anymore!