eclipse luna 格式打印
eclipse luna format printing
我已经下载了eclipse Luna。但是格式打印不起作用。让我们考虑下面给出的简单代码:
public class Test {
public static void main(String args[]) {
int a=4;
System.out.printf("%d",a);
}
}
下面显示错误消息:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int)
可能的原因和解决方法是什么?
尝试使用 format
方法:
int a = 4;
System.out.format("%d", a);
我正在使用 Eclipse Luna
,下面的 main
方法为我运行:
public class Whosebug {
public static void main(String[] args) {
int a = 4;
System.out.printf("%d", a);
}
}
给我输出:
4
您的 Compiler compliance level
可能不正确。
您可以在 Eclipse 中找到它:
项目 > 属性 > Java 编译器
确保将其设置为 1.5 或更高。
我从@Katja Christiansen 的评论中得到了答案。评论已在下面给出,因为@Katja Christiansen 没有在 asnswer 中写下解决方案,因为我在这里写它让其他人可以发现问题已经解决..
"Maybe project specific compiler settings are enabled? Open the properties of your Java project, select "Java Compiler”并检查 "Enable project specific settings" 是否启用,以及所选 JDK 是否与 Eclipse JDK 设置不同。 – Katja Christiansen “
尝试之后,printf 已经解决了,它解决了所有现有项目。
感谢@Katja Christiansen 的合作。
我已经下载了eclipse Luna。但是格式打印不起作用。让我们考虑下面给出的简单代码:
public class Test {
public static void main(String args[]) {
int a=4;
System.out.printf("%d",a);
}
}
下面显示错误消息:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int)
可能的原因和解决方法是什么?
尝试使用 format
方法:
int a = 4;
System.out.format("%d", a);
我正在使用 Eclipse Luna
,下面的 main
方法为我运行:
public class Whosebug {
public static void main(String[] args) {
int a = 4;
System.out.printf("%d", a);
}
}
给我输出:
4
您的 Compiler compliance level
可能不正确。
您可以在 Eclipse 中找到它: 项目 > 属性 > Java 编译器
确保将其设置为 1.5 或更高。
我从@Katja Christiansen 的评论中得到了答案。评论已在下面给出,因为@Katja Christiansen 没有在 asnswer 中写下解决方案,因为我在这里写它让其他人可以发现问题已经解决..
"Maybe project specific compiler settings are enabled? Open the properties of your Java project, select "Java Compiler”并检查 "Enable project specific settings" 是否启用,以及所选 JDK 是否与 Eclipse JDK 设置不同。 – Katja Christiansen “
尝试之后,printf 已经解决了,它解决了所有现有项目。
感谢@Katja Christiansen 的合作。