What is the comparable interface, JAVA Programming

Assignment Help:

What is the Comparable interface?

Comparable interface is used to sort arrays and collections of objects using collections.sort() and java.utils. Objects of the class implementing Comparable interface can be ordered. All classes implementing Comparable interface should implement the compareTo() method which has the return type as an integer. Signature of compareTo() method is as below:

int i = object1.compareTo(object2)

  • If object1 < object2: The value of i returned will be negative.
  • If object1 > object2: The value of i returned will be positive.
  • If object1 = object2: The value of i returned will be zero.

 


Related Discussions:- What is the comparable interface

INHERITANCE, Did Java support hybrid inheritance?

Did Java support hybrid inheritance?

Explain preemptive scheduling and time slicing, In preemptive scheduling, t...

In preemptive scheduling, the highest priority task executes until it enters the waiting or dead states or a higher priority task comes into existence. In time slicing, a task i

Use the constructor, Can we use the constructor, instead of init(), to init...

Can we use the constructor, instead of init(), to initialize servlet? Ans) Yes. Of course you can use the constructor instead of init(). There's nothing to stop you. But you sho

What is jdbc abstraction and dao module, Using this module we can keep up t...

Using this module we can keep up the database code clean and easy, and prevent problems that result from a failure to close database resources. A new layer of meaningful exceptions

Week 7, This is a two part project, one in Alice, and another in Java. You ...

This is a two part project, one in Alice, and another in Java. You can either zip the files together as one and upload the single zip file, OR upload the separate files. If you dec

Explain the relational operator precedence, Explain the Relational Operator...

Explain the Relational Operator Precedence ? Whenever a new operator is introduced you have to ask yourself whereas it fits in the precedence tree. If you seem back at the ins

What is the difference between inner class and nested class, What is the di...

What is the difference between inner class and nested class? When a class is explained within a scope od another class, then it becomes inner class. If the access modifier o

What is jdbc exactly, What is JDBC exactly? Describe the steps required to ...

What is JDBC exactly? Describe the steps required to execute a SQL query using JDBC.

Explain primitive and abstract data type in java, Question 1 Describe any ...

Question 1 Describe any five buzz words in Java Question 2 Describe exception classes and also explain common exceptions in java Question 3  Describe primitive and

How are this () and super() used with constructors, How are this () and sup...

How are this () and super() used with constructors? this() Constructors: is used to pointing current class instance. Can be used with methods or variables. Used to call

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd