Long size comparison type, long type and the difference between type Long

Today write code found found a local program is normal, but to send the test environment is not normal, the spirit of skepticism data link test database, debugger found that the data is indeed a problem, and then the data in what place? Was found to be equal teamGroupId user belongs is determined and the current user teamGroupId

When there is a problem, then test and validate a bit Long  

1. basic types: Long, int, byte, float, Double, char
2. object type (class): Long, Integer, Byte, Float, Double, Char, String, all other java provided, or create your own class .

Copy the code
com.lk.test Package; 

public class TestHundun { 
    public static void main (String [] args) { 
        / ** 
         * Long base type 
         * Long object type, when compared: If the verification is taken equal to the address, the value of ( -128 to 127) is equal to 
         * values taken because this is the same address, not equal to the remaining, available verify equal longValue in (), is available the equals (); 
         * / 
        Long a = 123456; 
        Long B = 123456; 

        C 123456L = Long; 
        Long D = 123456L; 
        Long E = 123457L; 
        
        System.out.println ( "(Long) A == B:" + (A == B)); 
        System.out.println ( "(Long) D c ==: "+ (c == D)); 
        System.out.println (" (Long) D <E: "+ (D <E)); 
        System.out.println (" c == correctly validate d: "+ (c = null && c.equals (d)!)); 
        System.out.println (" longValue in (): " + (c.longValue () == d.longValue ( )));
    }

}
Copy the code

Output:

(Long) A == B: to true
(Long) C == D: to false
(Long) D <E: to true
right == validation D C: to true
longValue in (): to true

Guess you like

Origin www.cnblogs.com/zhuyeshen/p/12081286.html