Return | Method | Summary |
---|---|---|
int | compareTo(Long anotherLong) | Compares two Long objects numerically. |
boolean | equals(Object obj) | Compares this object to the specified object. |
compareTo(Long anotherLong) returns
Value | Meaning |
---|---|
0 | if this Long is equal to the argument Long; |
less than 0 | if this Long is numerically less than the argument Long; |
greater than 0 | if this Long is numerically greater than the argument Long. |
public class Main {
public static void main(String[] args) {
Long long1 = new Long(12345L);
Long long2 = new Long("12346");
System.out.println(long1.compareTo(long2));
}
}
The output:
-1
If you just want to check the equality,
public class Main {
public static void main(String[] args) {
Long long1 = new Long(12345L);
Long long2 = new Long("12346");
System.out.println(long1.equals(long2));
}
}
The output:
false
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |