Java Java Basics Getting Started with Java Strings, Variables, and Formatting

what is wrong with this code ???

i have done every possible thing but it does not accept it
Console console = System.Console();
String firstName = "botan";
  console.printf("my name is %s" , FirstName);

1 Answer

Treehouse Moderator 18,371 Points

Hmm...I'm not sure at which step you're getting stuck, but as a general code challenge hint - it's usually a good idea to do only what they ask for. Sometimes adding extra code, even if it's correct, can cause the challenge to fail.

In this case, you don't need the import and console setup lines. They have done that for you already. You should also always use the exact string they suggest in the challenge directions. Java variables are also case-sensitive.

// import; -- they have setup a console for you.
// Console console = System.Console(); -- so you don't need these lines.
String firstName = "botan"; // Looks good here!
console.printf("my name is %s" , FirstName); // FirstName is case sensitive, should be firstName.
// Use the string, "<YOUR NAME> can code in Java!" for part 2 of 3. You don't need formatting for this step.
// For the next part, you'll use string formatting like you're doing above. Just make sure you're using the exact string they ask for. ("%s can code in Java!")

Hopefully that should help you get started, but let me know if you still run into issues and we can walk through a solution. Happy coding!

Exactly , I figured it out and the problem was the extra codes that I wrote which the system didn’t require it from me ! Thanks a lot .