• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Comparator interface Java SE 8, OCPJP 8, Class type of Object

 
Greenhorn
Posts: 4
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can you explain me more clearly what type of object is byName is ? And where should i find the information about this type (or operation)  in Java SE 8 Doc .
System.out.println(byName.getClass()) result is class DuckHelper$$Lambda$1/990368553

Code below:

// Duck class


// DuckHelper class:


Thank you for your help

 
Marshal
Posts: 79179
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

If this question fomes from a book, please tell us full details of the book.

Tuan Dang wrote:. . . what type of object is byName . . . ?

DuckHelper$$Lambda$1/990368553
This is a λ. You are using a λ here to replace an anonymous class, as you would have used in Java7−. It is rarely necessary to find out its originating class, which you cannot find. Since the λ usually has local scope and doesn't even exist outwith the method it is declared in, all the information about it is in its code.

And where should i find the information about this type (or operation)  in Java SE 8 Doc . . .

If the λ has local scope, or is a private field, it would be impossible to write documentation comments and have them displayed. The javadoc tool displays neither local variables nor private members of a class, so there is no such thing as documentation to find.
You can find tutorials and books about λs however. If the λ uses default methodss from Comparator, you can find their details under Comparator.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can even use lambdas or method references for non-private fields. For instance:

The declared type is all that matter here - Comparator. When you print out their classes (or their instances) you'll still get non-useful results, but I believe that's also the case for String.CASE_INSENSITIVE_ORDER.
 
Tuan Dang
Greenhorn
Posts: 4
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for clarifying!
 
reply
    Bookmark Topic Watch Topic
  • New Topic