今天寫代碼發現發現本地程序是正常的,但是發送到測試環境就不正常了,本着對數據的懷疑態度鏈接了測試數據庫,調試程序發現,確實是數據問題,然后數據出現在什么地方呢?才發現是在判斷用戶所屬的teamGroupId和當前用戶teamGroupId相等
時出現了問題,於是測試和驗證了一下Long
1.基本類型:long,int,byte,float,double,char
2. 對象類型(類): Long,Integer,Byte,Float,Double,Char,String,其它一切java提供的,或者你自己創建的類。
package com.lk.test; public class TestHundun { public static void main(String[] args) { /** * long 是基本類型 * Long是對象類型,進行比較時:若驗證相等則取地址,數值為(-128~127)則相等, * 因為這段數值取的是相同的地址,其余的則不相等,驗證相等可用longValue(),可用equals(); */ long a = 123456; long b = 123456; Long c = 123456L; Long d = 123456L; Long e = 123457L; System.out.println("(long)a==b:"+(a==b)); System.out.println("(Long)c==d:"+(c==d)); System.out.println("(Long)d<e:"+(d<e)); System.out.println("正確驗證c==d:"+(c!=null&&c.equals(d))); System.out.println("longValue():"+(c.longValue()==d.longValue())); } }
輸出結果:
(long)a==b:true
(Long)c==d:false
(Long)d<e:true
正確驗證c==d:true
longValue():true