有没有人可以帮我解决这个问题。我知道这可能是你可以用java编写的最简单的东西,但我无法想象它为我的生活。我刚开始学习java,这让我陷入困境。 当我编译代码它得到错误“INT不能转换为字符串console.printf(XY);int不能转换为字符串
import java.io.Console;
public class ExampleProgram {
public static void main(String[]arg) {
Console console = System.console();
console.printf("Below is a Power Calculation");
int x = 2;
int y = 2;
int xy = x * y;
console.printf(xy);
}
}
你不应该使用的toString()? – Ian
'printf(%d,xy)' –
返回错误:int无法取消引用 –