Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the issue compareTo() method in Java?public int compareTo(Object o){ Employee emp = (Employee) emp; return this.id - o.id;} id integer

user-image
Question added by Muhammed Rahshad Koyippalli , Cisco DNAC Senior Escalation Engineer , Cisco Systems - India
Date Posted: 2014/05/24
Naser Ali
by Naser Ali , Technical Specialist , Robert Bosch Engineering and Business Solutions India Pvt. Ltd

When you use subtraction, there is a possibility that you might overrun the limit of the integers and it might return a bad result. Because integer ranges from -32767 to +32768... so when you overstep this range through subtraction, it may produce undesired results.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.