FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Comparable and Comparator
NewsWeb Development

Comparable and Comparator

via Dev.to ReactDinesh G1mo ago

Comparable Interface Comparable Interface is meant for default natural Sorting order . It is present in Java.lang package . it is Contains Only one method Compare To() . Compare To() method is responsible to sort the elements . You define the natural ordering for your objects by implementing the Comparable’s compareTo(T o) method in your custom objects . For example, if we want to compare the Person object based on the first name we’ll implement the Comparable interface . import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class ComparatorExample { public static void main(String[] args) { ArrayList al = new ArrayList(); al.add("jai"); al.add("vijay"); al.add("maddy"); al.add("ajai"); al.add("don"); Collections.sort(); System.out.println(al); } } Comparator Interface Comparator Interface is meant for Customized Sorting Order . It is present in Java.util . It contains two method Compare() method and equals() . Compare()method is responsible to so

Continue reading on Dev.to React

Opens in a new tab

Read Full Article
17 views

Related Articles

The most useful command in the age of agentic
News

The most useful command in the age of agentic

Dev.to • 4d ago

️ The 5IR Hardware Patch: The Syntropic Processor
News

️ The 5IR Hardware Patch: The Syntropic Processor

Medium Programming • 4d ago

These 5 Amazon Spring Sale deals are HSA and FSA eligible
News

These 5 Amazon Spring Sale deals are HSA and FSA eligible

ZDNet • 4d ago

Rank the 50 best Apple products
News

Rank the 50 best Apple products

The Verge • 4d ago

At Gaza’s Al-Shifa Hospital, the War Isn’t Over
News

At Gaza’s Al-Shifa Hospital, the War Isn’t Over

Wired • 4d ago

Discover More Articles