我在我的申请一类其中int值存储:转换int数组为int
Characters.class:
public int charPunch(int q) {
int[] charPunch = {
15,
10,
20,
25,
20,
20,
15,
20,
20,
25
};
return charPunch(q);
}
的q
值由用户字符选择决定。我试图理解代码,因此只是现在发布的代码。
在同一个类文件中,我有一个字符串数组,然后可以使用.toString()转换(在另一个.class文件中)。
Game.class:
oneName = Ch.charName(q).toString();
这给playerOne的oneName
数组值和转换字符串数组结果到单个字符串和作品!
我的问题是:我能够做一个完全相同的东西来int数组的数组?
会改变int数组到字符串数组,字符串数组转换为一个字符串,然后将字符串转换为int是可怕的节目,但我的最好的解决办法?
String onePunch = charPunch(q).toString(); int charPunchInt = Integer.parseInt(charPunch);
我目前在Characters.class阵列的返回线获得StackOverflowError
直到进程放弃。
如果转换的int数组到一个整数。那个整数是多少? – Christian
我不明白这个问题,但是你得到StackOverflowError,因为在你的方法中你调用递归的charPunch而没有退出条件 – Karura91