我很抱歉,如果这已经被问过,但我无法找到一个决定性的答案经过一些广泛的搜索,所以我想我会问这里。我是Java的初学者(通常是编码),他的任务是编写一个程序,它接受用户输入的3位数字,并添加这三位数字。如何使用Java将整数分割为数组?
注意:我不能使用循环执行此任务,并且三位数字必须全部输入一次。
String myInput;
myInput =
JOptionPane.showInputDialog(null,"Hello, and welcome to the ThreeDigit program. "
+ "\nPlease input a three digit number below. \nThreeDigit will add those three numbers and display their sum.");
int threedigitinput;
threedigitinput = Integer.parseInt(myInput);
为什么你想创建一个数组?为什么不把每个数字从输入字符串中拉出来并添加呢?这听起来像一个[XY问题](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem)给我。 – azurefrog 2014-10-11 21:49:29