2011-07-21 22 views

回答

4

例如如果你投入很長時間,你會丟棄長整數的較高位。

Short -> Byte 
0x00FF -> 0xFF 
256 -> -128 
0

這是一個簡短的,精心挑選的答案。

public class Narrow { 
public static void main(String[] args) { 
    int i; 
    short s; 

    i = 32768; 
    s = (short) i; 
    System.out.println("int of " + i + " becomes a short of " + s); 
} 
} 

我是2^15,或者比MAX_VALUE短一個。

Java將回復int of 32768 becomes a short of -32768