• 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

Questions on Comparable interface

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Questions on Comparable interface

1. Is comparable a functional interface?
2. Can comparable be used with lambda expressions?
 
Bartender
Posts: 5465
212
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) yes
2) yes, for instance (nonsense example)

Can you explain the outcome?
 
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

J Mohandos wrote:Questions on Comparable interface

1. Is comparable a functional interface?
2. Can comparable be used with lambda expressions?


The answer to your first question can easily be seen in the documentation: https://docs.oracle.com/en/java/javase/16/docs/api/java.base/java/util/Comparator.html

The answer to your second question will be automatically answered by the answer to your first question, because lambda expressions can only be used with functional interfaces.
 
reply
    Bookmark Topic Watch Topic
  • New Topic