今天來認識這兩個整數類型:byte與 short
Java byte數據類型
Java short數據類型
package com.sea.java8;
public class OpTest1 {
public static void main(String[] args) {
byte var1 = 10, var2 = 3;
//byte var3 = var1 + var2; 無法計算
var1++;
System.out.println(var1);
var1 += 100;
System.out.println(var1);
System.out.println(++var1);
System.out.println(var1); // 112
System.out.println(var1++); //++在後,之後才++
System.out.println(var1);
var1 += 14;
System.out.println(var1);
var1 += 1; //建議別超出範圍!
System.out.println(var1);
}
}
依序run出: