Java中System.out.printf参数传递错误分析与修正

在Eclipse中使用System.out.printf方法进行格式化打印时,如:System.out.printf("%5d", i),

会提示错误描述:The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String,int)

此处的int可以换成其他基本数据类型如double,long等等;

查看printf()方法定义的路径为:java.io.PrintStream.printf(Locale, String, Object...)和java.io.PrintStream.printf(String, Object...),也就是所在的包java.io,类为PrintStream.class。

错误和JDK的本版相关,具体的原因是Java Compiler中Compiler comlicance level的数值太低。将Compiler comlicance level设置为不小于1.5,重新建立工程即可。

方法:Project >> Properties >> Java Compiler >> Compiler comlicance level。

---------------------------

PS:初学Java,仅供参考。


  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值