Eclipse Java printf问题PrintStream不适用 [英] Eclipse Java printf issue PrintStream is not applicable

查看:379
本文介绍了Eclipse Java printf问题PrintStream不适用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个编程课程的介绍,我的Eclipse问题似乎不想以最简单的形式运行 printf

I'm doing a intro to programming course and I'm having issues with my Eclipse that doesn't seem to want to run printf in even its simplest form.

我的代码是:

package Practice;

import java.io.*;

public class Printf {

    public static void main(String[] args) throws IOException
    {
        int num1 = 54;
        int num2 = 65;    
        int sum = num1 + num2;
        System.out.printf("Sum of %d and %d is %d.", num1, num2, sum);
    }
}

错误就是说


类型 PrintStream中的方法 printf(String,Object []) / code>不适用于参数(String,int,int,int)

The method printf(String, Object[]) in the type PrintStream is not applicable for the arguments (String, int, int, int)

我将Java编译器合规性级别设置为1.8,因此我应该没有问题,因为我在之前的帖子中已经阅读过。 Kepler版本的Eclipse已经应用了Java 8补丁(所以我可以遵守1.8)

I have the Java compiler compliance level set to 1.8 so it should have no issues as I have read in previous posts. Kepler version of Eclipse has had the Java 8 patch applied (so I could comply with 1.8)

我找不到的网站给了我任何其他关于问题的线索可能是吗?

No site I have found has given me any other clues as to what the issue could be?

推荐答案

结果Eclipse中的项目文件夹运行在他们自己的属性上,从Eclipse主设置中分离出来..按顺序对于他们在版本1.6 / 1.7 / 1.8上编译你必须从主要设置中单独更改他们的属性...

Turns out the project folders in Eclipse run on their own properties seperate from the Eclipse main settings .. in order for them to compile on version 1.6/1.7/1.8 you have to change their properties seperatly from the main settings...

基本上不是去windows> preferances .. 。在Package Explorer> Properties> Java Compiler中右键单击项目文件夹更改和更新编译器版本然后检查启用项目特定设置,然后将下面的设置更改为1.5或更高的编译器合规性级别,以便此代码以上工作。

Basically instead of going to windows > preferances ... to change and update the compiler version you right click on the project folder in Package Explorer > Properties > Java Compiler then check the Enable project specific settings and then Change the settings below to the compiler compliance level of 1.5 or higher in order for this code above to work.

为什么这样做我不知道什么都没有,但它至少现在有效:)

Why it does that i have no idea makes no sence but it at least works now :)

这篇关于Eclipse Java printf问题PrintStream不适用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆