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

Klaudia Krol
Klaudia Krol
576 Points

Challange 2 printf on console object ??please help

How to propely write down this code challenge as Im stock ?

Console.printf("Klaudia"); - what is incorrect here ?

Jason Anders
Jason Anders
Treehouse Moderator 145,858 Points

Could you provide a link to the actual Challenge. This will make it easier for us to help you troubleshoot. Just copy/paste the URL into a comment here.

Klaudia Krol
Klaudia Krol
576 Points

Thank you -:) Great help . It works

2 Answers

Hi

See if this helps:

import java.io.Console;

public class PrintYourName {

    public static void main(String[] args) {

        Console console = System.console();

        // Your code goes below here

        String firstName = "Sam";

        console.printf("Hello, my name is %s\n", firstName);

  }

}

This is an answer that was posted here: https://teamtreehouse.com/community/call-the-printf-function-on-the-console-object-and-make-it-print-out-your-name-can-code-in-java

Moderator Edited: Added markdown to the code so it is readable in the Community Forum. Also changed reply from a 'Comment' to 'Answer,' so it may be upvoted and/or marked as Best Answer.

Kourosh Raeen
Kourosh Raeen
23,733 Points

Hi Klaudia Krol - Use System.out.printf() instead of Console.printf(). Also the challenge is asking you to print the string "Klaudia can code in Java!".