public static void main(String[] args) {
//call for input
System.out.println("Please Enter a 3-digit number..");
Scanner in = new Scanner(System.in);
int[] num = new int[3];
for (int i = 0; i < num.length; i++) {
int val = in.nextInt();
num[i] = val;
}
System.out.println("The Sum of the numbers is " + sumNums);
System.out.println("The Reverse of the numbers is " + reverseNums);
}
public int sumNums(int x) {
return num[0] + num[1] + num[2];
}
public in reverse(int x) {
return num[2] + num[1] + num[0];
}
我正在尝试创建几个添加分解数字的方法,例如,如果我输入 123,它将导致 1+2+3=6,但我不断收到“找不到符号”。我分解输入的方式也是最有效的吗?