In Java we often have to make some judgments, and for judgment, the most used is the ">", "= =", "<" comparison, here we do a long type of data and long data comparison of the size of the explanation.
The difference between a long and long in JavaThere are two types of data in Java:1. Basic type:byte (8), short(+),int (+), long (+), float (+), double (+), char (+), Boolean (1)2. Object type: Byte,short,integer,long,float,double,character,boolean
the above object types are basic types of wrapper classes, for example, Byte is a wrapper class of byte
The Java language is an object-oriented language, but the basic data types in Java are not object-oriented, which in the actual use of a lot of inconvenience, in order to solve this shortcoming, in the design of the class for each basic data type to design a corresponding class to represent, The classes that correspond to the eight basic data types are collectively referred to as wrapper classes (Wrapper Class)
For the wrapper class, the use of these classes consists of two main types:
A, as the basic data type corresponding to the class type exists, convenient to involve the operation of the object.
b, contains the relevant attributes for each basic data type, such as maximum, minimum, and related methods of operation.
comparison of the size of Long datafor long type of data, this data is an object, so the object can not be directly through the ">", "= =", "<" comparison, if you want to compare the equality of two objects, we can use the. Equals () method of the Long object:
Long L1 = new long (+); Long L2 = new long (n); System.out.println (L1.equals (L2));
If you want to make a comparison of ">", "<", you can use the long object's. Longvalue () Method:
Long L1 = new long (+); Long L2 = new long (n); System.out.println (L1.longvalue () <l2.longvalue ());
comparison of the size of Long datafor Long data, this data is a basic data type, not an object, so it can be compared directly with ">", "= =", "< "
Long L3 = +; Long L4 = n; System.out.println (L3>L4); System.out.println (L3<L4); System.out.println (L3==L4);
Love dumplings: Long type and long type in Java comparison size