Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

Paul LeDuc
Paul LeDuc
7,844 Points

[SOLVED] Java printf not seeming to work for me?

I have the following code:

package p;

import java.io.*; 

public class Test  {

    // -----------------------------------------------------------------------
    // Constants.
    // -----------------------------------------------------------------------
    public final static String TAG = Test.class.getSimpleName(); 

    // -----------------------------------------------------------------------
    // Members.
    // -----------------------------------------------------------------------
    private long mDuration  = 0;                            

    // -----------------------------------------------------------------------
    // Constructors.
    // -----------------------------------------------------------------------
    public Test(long milliseconds) {
        mDuration = milliseconds;
    }


    // -----------------------------------------------------------------------
    // Methods.
    // -----------------------------------------------------------------------
    public void start() {
        System.out.printf("%-6d: \n", mDuration);

    }
}

The message I am receiving is that the method printf(String, Object[] in the type PrintStream is not applicable for arguments (String, long)

What am I missing?

Paul LeDuc
Paul LeDuc
7,844 Points

Apparently, this was a result of a project setting in Eclipse. It had to do with the Java Compiler compliance level.

Ken Alger
Ken Alger
Treehouse Teacher

Edited for markup and [SOLVED].

Please see this post for directions on how to post to the forum.