• 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

Where is the return type in this Method?

 
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good Day Dear ..

in java 8 there is a new release of new method inside the interface which is the default method .. that contains implementation.

there is a lot of method .. I just will take one only as example :



First of all .. I really tried to know how the method works as I failed .. Second .. I really don't know where is the return type .. ??


Help Please ..

Thanks
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Waseem Swaileh wrote:I just will take one only as example :



First of all .. I really tried to know how the method works as I failed .. Second .. I really don't know where is the return type .. ??



The return type of the method is "Comparator<T>" (a Comparator instance, with a generic of type T). As for what the generic type is, that is a bit more complex. It is determined by the compiler during the method calls, and it is bounded... it is "<T extends Comparable<? super T>>".

Henry
 
Waseem Swaileh
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:

The return type of the method is "Comparator<T>" (a Comparator instance, with a generic of type T). As for what the generic type is, that is a bit more complex. It is determined by the compiler during the method calls, and it is bounded... it is "<T extends Comparable<? super T>>".

Henry



It seems like complex to me yes .. Thanks Henry ...

Correct me if I am wrong ...



T in Comparator should extends Compatable, as Compatable's generic type should be subclass for the same T ?

and in end .. Comparator instance should be return with the specify T.

Regards

reply
    Bookmark Topic Watch Topic
  • New Topic