• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where is the return type in this Method?  RSS feed

 
Waseem Swaileh
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!