The Long class in java.util package is a wrapper class that wraps a value of the primitive type long in an object. It provides methods to perform various operations on long data type values, such as arithmetic operations, comparison operations, and conversions to and from other data types.
Code Examples:
1. To compare two Long objects for equality using the equals() method:
Long l1 = 100L; Long l2 = new Long(100);
if (l1.equals(l2)) { System.out.println("Both Long objects are equal"); } else { System.out.println("Long objects are not equal"); }
Output: Both Long objects are equal
2. To compare two long values for equality using the equals() method:
long l1 = 100L; long l2 = 100L;
if (l1 == l2) { System.out.println("Both long values are equal"); } else { System.out.println("long values are not equal"); }
Output: Both long values are equal
Package Library:
The Long class is part of the java.util package library.
Java Long.equals - 20 examples found. These are the top rated real world Java examples of java.util.Long.equals extracted from open source projects. You can rate examples to help us improve the quality of examples.