File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Cattle Drive and the fly likes help with a weird block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "help with a weird block" Watch "help with a weird block" New topic
Author

help with a weird block

Daniel Loranz
Ranch Hand

Joined: Jun 17, 2008
Posts: 41
This is me --->

I need help understanding the following block structure.



I see ... Class.method(arguments, very strange things embedded in argument list);
Very disturbing. Please help.

Thanks.


[ July 25, 2008: Message edited by: Daniel Loranz ]

Hmmm - angle brackets don't appear to display correctly even inside code tags. I'll sub [ and ] for angle brackets.
[ July 25, 2008: Message edited by: Daniel Loranz ]
Brian Holsenbeck
Greenhorn

Joined: Jul 01, 2008
Posts: 8
Look at the Collections class on the api:

http://java.sun.com/j2se/1.5.0/docs/api/

It has a sort routine that wants a list, and something that implements the Comparator interface:

sort(List<T> list, Comparator<? super T> c)

You *could* create a class that implements Comparator outside the call; new an instance of that class; then pass the new instance of that class. This, however, lets you create a class on the fly (I think it's called an anonymous class; someone will call me on that if I'm wrong, I'm sure), and pass a new instance of that anonymous class as the comparator. The Comparator only wants a way to compare 2 instances of your list.

Hope the above makes sense. I'd have trouble writing it, but I *think* I understand it.

Hello from a new cattle drive guy, btw! I've just sent in 1b recently. I'm sure I'll have lots of questions posted soon.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with a weird block