我有这个简单的java代码:
package cal;
import java.util.Scanner;
public class cal {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int n1,
n2,
sum;
System.out.print("enter first: ");
n1 = input.nextInt();
System.out.print("enter second: ");
n2 = input.nextInt();
sum = n1 + n2;
System.out.printf("sum is %d\n", sum);
}
}
错误在'printf',它需要(string,object []),我的'sum'是int但不能被视为对象?
实际上,首先这段代码运行良好,但在我对工作场所的路径进行了一些更改后,代码开始出现此错误