Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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.