• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

help with a weird block

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
    Bookmark Topic Watch Topic
  • New Topic