將整數轉換爲int數組時,例如123轉換爲{1,2,3},我得到值{49,50,51}。 無法找到我的代碼有問題。整數打印錯誤值
public class Test {
public static void main(String [] args) {
String temp = Integer.toString(123);
int[] newGuess = new int[temp.length()];
for (int i = 0; i < temp.length(); i++) {
newGuess[i] = temp.charAt(i);
}
for (int i : newGuess) {
System.out.println(i);
}
}
}
輸出:
[在Java中將整數轉換爲int數組]可能的副本(http://stackoverflow.com/questions/39482457/converting-an-integer-into-an-int-array-in-java) –