我就廢話不多說了,大家還是直接看代碼吧~

public static void main(String[] args) {
// 1、將long型轉(zhuǎn)化為int型,其中int、long是基礎(chǔ)類型
long a = 10;
int b = (int) a;
System.out.println("1、將long型轉(zhuǎn)化為int型:" + b);
// 2、將int型轉(zhuǎn)化為long型,其中int、long都是基礎(chǔ)類型
int a1 = 10;
long b1 = a1;
System.out.println("2、將int型轉(zhuǎn)化為long型:" + b1);
// 3、將Long型轉(zhuǎn)換為int型的,其中Long型是包裝類型
Long a2 = 10l;
int b2 = a2.intValue();
System.out.println("3、將Long型轉(zhuǎn)換為int型:" + b2);
//4、將Integer型轉(zhuǎn)化為long型,其中Integer型是包裝類型,long型是基礎(chǔ)類型
Integer a3=10;
long b3=a3.longValue();
System.out.println("4、將Integer型轉(zhuǎn)化為long型:"+b3);
//5、將Integer型轉(zhuǎn)化為Long型,其中Integer、Long型都是包裝類型
Integer a4=10;
Long b4=a4.longValue();
System.out.println("5、將Integer型轉(zhuǎn)化為Long型:"+b4);
}
新聞名稱:java中l(wèi)ong(Long)與int(Integer)之間的轉(zhuǎn)換方式-創(chuàng)新互聯(lián)
網(wǎng)頁路徑:http://chinadenli.net/article0/dgheio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站策劃、做網(wǎng)站、定制開發(fā)、網(wǎng)站改版、App開發(fā)、網(wǎng)站導航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)