简体   繁体   English

Java中的System.out.format

[英]System.out.format in Java

I'm trying to make a formatted output in Java but I'm having some trouble... I write for example: 我正在尝试用Java进行格式化输出,但是遇到了一些麻烦...例如,我写:

System.out.format ("%d", 5);

but Eclipse underlines the word "format" and there is a marker at this line saying: 但是Eclipse在“格式”一词下加了下划线,这行上有一个标记说:

The method format(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int). 类型PrintStream的方法format(String,Object [])不适用于参数(String,int)。

Most likely the problem is that you are not using Java 1.5 or higher. 最有可能的问题是您没有使用Java 1.5或更高版本。 Please check the version in your build. 请检查内部版本。 In Eclipse, this is: 在Eclipse中,这是:

  • Right Click on the Project -> Build Path -> Configure Build Path 右键单击项目->构建路径->配置构建路径
  • Choose Libraries tab, click on JRE System Library then choose Edit 选择“库”选项卡,单击“ JRE系统库”,然后选择“编辑”。
  • Change your execution environment to one that is Java 1.5 or higher in the drop down. 在下拉列表中将您的执行环境更改为Java 1.5或更高版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM