例如:+7 符號位 數值爲: 0000 0111spa
其反碼=源碼=補碼=0000 0111code
例如:-7 符號位 數值爲: 1000 0111blog
源碼是:1000 0111get
反碼是:1111 1000源碼
補碼是:1111 1001class
public static void main(String[] args) { char numChar = '3'; int intNum = numChar - '0'; System.out.println(numChar + ": " + intNum);//3: 3 }
public static void main(String[] args) { char numChar = '9'; int intNum = Character.getNumericValue(numChar); System.out.println(numChar + ": " + intNum); //9: 9 }