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

Digital clock, how to Using polymorphism to write a program to display digi...

how to Using polymorphism to write a program to display digital clock?

Caesar Cipher, How can I create a simple Caesar cipher using if-else statem...

How can I create a simple Caesar cipher using if-else statements?

Explain about core java, Java is increasingly used for middleware applicati...

Java is increasingly used for middleware applications to communicate among Server and clients. Java has features like multithreading, portability and networking capabilities. Chang

Homography matrix, Open A java applet should appear on your screen. C...

Open A java applet should appear on your screen. Click on File, OpenImage and select Asterix. Check Homography box. By clicking on the images you can select points. The c

Define testing with respect to programming, Define testing with respect to ...

Define testing with respect to programming? Testing is the process through that we try to determine the presence defects in a program. Testing is an significant step in soft

Excel file to responsive css/html page, Excel File to Responsive CSS/HTML p...

Excel File to Responsive CSS/HTML page Project Description: Excel file to be converted into a responsive form for a site. In the excel file you will see where the input field

Control structures, JavaScript supports the normal control structures: ...

JavaScript supports the normal control structures: The conditionals if, if...else, & switch; The iterations for, while, do...while, break, & continue;

INHERITANCE, Did Java support hybrid inheritance?

Did Java support hybrid inheritance?

Online music store application, An online music store offers all songs for ...

An online music store offers all songs for 3$ each. The store requires members to prepay any amount of money they wish, and then download as many songs accordingly. You are require

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