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 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

Name.java
import java.io.Console;
Console console = System.Console();
String firstName = "botan";
  console.printf("my name is %s" , FirstName);

1 Answer

rydavim
rydavim
18,814 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 java.io.Console; -- 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 .