SlideShare a Scribd company logo
1 of 1
Download to read offline
Comparable Interface
1.Comparable is the interface which is present in the java.lang package.
2.We can use this interface to arrange the user defined objects in an order.
3.This interface contains only one method compareTo(Object obj)
4.By using this we can sort the objects based on the single data Member of the objects.
Let ‘a’ and ‘b’ are the two objects.If we want to compare those two objects by using
compareTo(Object obj) method.We can compare like this:
a.compareTo(b);
Here ‘a ’ is called as the target object.Where as ‘b ‘ is called as passed in object.
If the Target Object is less than the Object that is passed in the return value is negative.
if ab return 1;
If the Target Object is equal to the Object that is passed in the return value is Zero.
If a==b return 0;
Solution
Comparable Interface
1.Comparable is the interface which is present in the java.lang package.
2.We can use this interface to arrange the user defined objects in an order.
3.This interface contains only one method compareTo(Object obj)
4.By using this we can sort the objects based on the single data Member of the objects.
Let ‘a’ and ‘b’ are the two objects.If we want to compare those two objects by using
compareTo(Object obj) method.We can compare like this:
a.compareTo(b);
Here ‘a ’ is called as the target object.Where as ‘b ‘ is called as passed in object.
If the Target Object is less than the Object that is passed in the return value is negative.
if ab return 1;
If the Target Object is equal to the Object that is passed in the return value is Zero.
If a==b return 0;

More Related Content

More from reyazansari001

You have 50 mL of each solution or .050 L. Molari.pdf
                     You have 50 mL of each solution or .050 L. Molari.pdf                     You have 50 mL of each solution or .050 L. Molari.pdf
You have 50 mL of each solution or .050 L. Molari.pdfreyazansari001
 
triosephosphate isomerase .pdf
                     triosephosphate isomerase                        .pdf                     triosephosphate isomerase                        .pdf
triosephosphate isomerase .pdfreyazansari001
 
Step1 In SO2; sulphur atom is attached to two ele.pdf
                     Step1 In SO2; sulphur atom is attached to two ele.pdf                     Step1 In SO2; sulphur atom is attached to two ele.pdf
Step1 In SO2; sulphur atom is attached to two ele.pdfreyazansari001
 
Indicators typically measure pH. The reaction pr.pdf
                     Indicators typically measure pH.  The reaction pr.pdf                     Indicators typically measure pH.  The reaction pr.pdf
Indicators typically measure pH. The reaction pr.pdfreyazansari001
 
i) we dont know the mixture so the reaction may.pdf
                     i) we dont know the mixture so the reaction may.pdf                     i) we dont know the mixture so the reaction may.pdf
i) we dont know the mixture so the reaction may.pdfreyazansari001
 
Yes it is always true. The company pays for these resources by eit.pdf
Yes it is always true. The company pays for these resources by eit.pdfYes it is always true. The company pays for these resources by eit.pdf
Yes it is always true. The company pays for these resources by eit.pdfreyazansari001
 
use good toolsSolutionuse good tools.pdf
use good toolsSolutionuse good tools.pdfuse good toolsSolutionuse good tools.pdf
use good toolsSolutionuse good tools.pdfreyazansari001
 
We can consider the following dataThe data is about students from .pdf
We can consider the following dataThe data is about students from .pdfWe can consider the following dataThe data is about students from .pdf
We can consider the following dataThe data is about students from .pdfreyazansari001
 
Transposons are the segments of DNA that can move around to differen.pdf
Transposons are the segments of DNA that can move around to differen.pdfTransposons are the segments of DNA that can move around to differen.pdf
Transposons are the segments of DNA that can move around to differen.pdfreyazansari001
 
The middle support should be at a position of (L ÷ square root of 2).pdf
The middle support should be at a position of (L ÷ square root of 2).pdfThe middle support should be at a position of (L ÷ square root of 2).pdf
The middle support should be at a position of (L ÷ square root of 2).pdfreyazansari001
 
C)Weak Acid, HF note HF is a weak acid that can.pdf
                     C)Weak Acid, HF  note HF is a weak acid that can.pdf                     C)Weak Acid, HF  note HF is a weak acid that can.pdf
C)Weak Acid, HF note HF is a weak acid that can.pdfreyazansari001
 
test answerSolutiontest answer.pdf
test answerSolutiontest answer.pdftest answerSolutiontest answer.pdf
test answerSolutiontest answer.pdfreyazansari001
 
The answers are well explained & appreciated . The graphs & photos r.pdf
The answers are well explained & appreciated . The graphs & photos r.pdfThe answers are well explained & appreciated . The graphs & photos r.pdf
The answers are well explained & appreciated . The graphs & photos r.pdfreyazansari001
 
Stages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdf
Stages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdfStages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdf
Stages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdfreyazansari001
 
Solution.b.Formula = Net income Total stake holder equity 100.pdf
Solution.b.Formula = Net income  Total stake holder equity 100.pdfSolution.b.Formula = Net income  Total stake holder equity 100.pdf
Solution.b.Formula = Net income Total stake holder equity 100.pdfreyazansari001
 
Solution 1It is clearly mentioned that Facebook is a publicly held.pdf
Solution 1It is clearly mentioned that Facebook is a publicly held.pdfSolution 1It is clearly mentioned that Facebook is a publicly held.pdf
Solution 1It is clearly mentioned that Facebook is a publicly held.pdfreyazansari001
 
Recall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdf
Recall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdfRecall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdf
Recall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdfreyazansari001
 
Part 2please rate thanksSolutionPart 2please rate thanks.pdf
Part 2please rate thanksSolutionPart 2please rate thanks.pdfPart 2please rate thanksSolutionPart 2please rate thanks.pdf
Part 2please rate thanksSolutionPart 2please rate thanks.pdfreyazansari001
 
Now, solubility or molarity = 0.41molL Now molarity = moles l.pdf
Now, solubility or molarity = 0.41molL Now molarity = moles  l.pdfNow, solubility or molarity = 0.41molL Now molarity = moles  l.pdf
Now, solubility or molarity = 0.41molL Now molarity = moles l.pdfreyazansari001
 
Mushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdf
Mushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdfMushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdf
Mushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdfreyazansari001
 

More from reyazansari001 (20)

You have 50 mL of each solution or .050 L. Molari.pdf
                     You have 50 mL of each solution or .050 L. Molari.pdf                     You have 50 mL of each solution or .050 L. Molari.pdf
You have 50 mL of each solution or .050 L. Molari.pdf
 
triosephosphate isomerase .pdf
                     triosephosphate isomerase                        .pdf                     triosephosphate isomerase                        .pdf
triosephosphate isomerase .pdf
 
Step1 In SO2; sulphur atom is attached to two ele.pdf
                     Step1 In SO2; sulphur atom is attached to two ele.pdf                     Step1 In SO2; sulphur atom is attached to two ele.pdf
Step1 In SO2; sulphur atom is attached to two ele.pdf
 
Indicators typically measure pH. The reaction pr.pdf
                     Indicators typically measure pH.  The reaction pr.pdf                     Indicators typically measure pH.  The reaction pr.pdf
Indicators typically measure pH. The reaction pr.pdf
 
i) we dont know the mixture so the reaction may.pdf
                     i) we dont know the mixture so the reaction may.pdf                     i) we dont know the mixture so the reaction may.pdf
i) we dont know the mixture so the reaction may.pdf
 
Yes it is always true. The company pays for these resources by eit.pdf
Yes it is always true. The company pays for these resources by eit.pdfYes it is always true. The company pays for these resources by eit.pdf
Yes it is always true. The company pays for these resources by eit.pdf
 
use good toolsSolutionuse good tools.pdf
use good toolsSolutionuse good tools.pdfuse good toolsSolutionuse good tools.pdf
use good toolsSolutionuse good tools.pdf
 
We can consider the following dataThe data is about students from .pdf
We can consider the following dataThe data is about students from .pdfWe can consider the following dataThe data is about students from .pdf
We can consider the following dataThe data is about students from .pdf
 
Transposons are the segments of DNA that can move around to differen.pdf
Transposons are the segments of DNA that can move around to differen.pdfTransposons are the segments of DNA that can move around to differen.pdf
Transposons are the segments of DNA that can move around to differen.pdf
 
The middle support should be at a position of (L ÷ square root of 2).pdf
The middle support should be at a position of (L ÷ square root of 2).pdfThe middle support should be at a position of (L ÷ square root of 2).pdf
The middle support should be at a position of (L ÷ square root of 2).pdf
 
C)Weak Acid, HF note HF is a weak acid that can.pdf
                     C)Weak Acid, HF  note HF is a weak acid that can.pdf                     C)Weak Acid, HF  note HF is a weak acid that can.pdf
C)Weak Acid, HF note HF is a weak acid that can.pdf
 
test answerSolutiontest answer.pdf
test answerSolutiontest answer.pdftest answerSolutiontest answer.pdf
test answerSolutiontest answer.pdf
 
The answers are well explained & appreciated . The graphs & photos r.pdf
The answers are well explained & appreciated . The graphs & photos r.pdfThe answers are well explained & appreciated . The graphs & photos r.pdf
The answers are well explained & appreciated . The graphs & photos r.pdf
 
Stages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdf
Stages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdfStages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdf
Stages of cell cycleFlow Cytometry Measurement of Cellular DNA Co.pdf
 
Solution.b.Formula = Net income Total stake holder equity 100.pdf
Solution.b.Formula = Net income  Total stake holder equity 100.pdfSolution.b.Formula = Net income  Total stake holder equity 100.pdf
Solution.b.Formula = Net income Total stake holder equity 100.pdf
 
Solution 1It is clearly mentioned that Facebook is a publicly held.pdf
Solution 1It is clearly mentioned that Facebook is a publicly held.pdfSolution 1It is clearly mentioned that Facebook is a publicly held.pdf
Solution 1It is clearly mentioned that Facebook is a publicly held.pdf
 
Recall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdf
Recall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdfRecall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdf
Recall Each Oxygen has 4 Electrons in its 2p bonding orbital. But .pdf
 
Part 2please rate thanksSolutionPart 2please rate thanks.pdf
Part 2please rate thanksSolutionPart 2please rate thanks.pdfPart 2please rate thanksSolutionPart 2please rate thanks.pdf
Part 2please rate thanksSolutionPart 2please rate thanks.pdf
 
Now, solubility or molarity = 0.41molL Now molarity = moles l.pdf
Now, solubility or molarity = 0.41molL Now molarity = moles  l.pdfNow, solubility or molarity = 0.41molL Now molarity = moles  l.pdf
Now, solubility or molarity = 0.41molL Now molarity = moles l.pdf
 
Mushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdf
Mushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdfMushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdf
Mushroom is the fruiting body of Basidiomycetes fungi. It is also kn.pdf
 

Recently uploaded

What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxCeline George
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesSHIVANANDaRV
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSAnaAcapella
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 

Recently uploaded (20)

What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 

Comparable Interface1.Comparable is the interface which is present.pdf

  • 1. Comparable Interface 1.Comparable is the interface which is present in the java.lang package. 2.We can use this interface to arrange the user defined objects in an order. 3.This interface contains only one method compareTo(Object obj) 4.By using this we can sort the objects based on the single data Member of the objects. Let ‘a’ and ‘b’ are the two objects.If we want to compare those two objects by using compareTo(Object obj) method.We can compare like this: a.compareTo(b); Here ‘a ’ is called as the target object.Where as ‘b ‘ is called as passed in object. If the Target Object is less than the Object that is passed in the return value is negative. if ab return 1; If the Target Object is equal to the Object that is passed in the return value is Zero. If a==b return 0; Solution Comparable Interface 1.Comparable is the interface which is present in the java.lang package. 2.We can use this interface to arrange the user defined objects in an order. 3.This interface contains only one method compareTo(Object obj) 4.By using this we can sort the objects based on the single data Member of the objects. Let ‘a’ and ‘b’ are the two objects.If we want to compare those two objects by using compareTo(Object obj) method.We can compare like this: a.compareTo(b); Here ‘a ’ is called as the target object.Where as ‘b ‘ is called as passed in object. If the Target Object is less than the Object that is passed in the return value is negative. if ab return 1; If the Target Object is equal to the Object that is passed in the return value is Zero. If a==b return 0;