*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Long object comparison" Watch "Long object comparison" New topic
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

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
Sheriff

Joined: Oct 13, 2005
Posts: 38508
    
  23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Long object comparison