aspose file tools
The moose likes Beginning Java and the fly likes Long object comparison Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Long object comparison" Watch "Long object comparison" New topic

Long object comparison

Bushra Binte
Ranch Hand

Joined: Nov 07, 2006
Posts: 60
Hi,I have to compare two long objects.I need to check if the values stored in the two Long objects is the same.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
As for every other well-implemented Java object, you normally use Object#equals() for this.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62298

Please take the time to choose the correct forum for your posts. This forum is for questions on JSF.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41624
Agree that the equals method is the simplest way to do it, and most probably the best. By long objects, you obviously mean Long objects.
As an alternative you can get the value as a primitive with the longValue() method. Or use the compareTo() method and see whether the result is 0.
Have you tried LearnNowOnline?
subject: Long object comparison