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

Blessing Twala
Blessing Twala
468 Points

Keep getting syntax errors Hi I'm Blessing, I keep getting syntax errors though everything seems to be coded correctly.

The challenge is to enter a string and assign my name to it. I do exactly as the video tells me but I keep getting syntax errors. This is really strange because I refer to the video to check if I did it correctly though I keep getting errors on all of the code. Please help as I'm losing valuable time stuck in this course.

Name.java
// I have setup a java.io.Console object for you named console
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! It would be interesting to see what code you've tried thus far that's failing so that we can say exactly where you're going wrong or not understanding. Could you please provide the code that you've tried that's not working? Instructions on how to post code to the forums can be found in the "Markdown Cheatsheet" link at the bottom of the "Add an Answer" section. Thanks! :sparkles:

Miguel Rivas
Miguel Rivas
4,902 Points

Hi Blessing, if you have some lines (even if they are commented with // ) similar to the first System.out.print you wrote, just delete them or make sure you are replacing the first line.

Your code should look something like this:

// I have setup a java.io.Console object for you named console

//First part of the challenge, just declare a 'String' with this format: [Type][name_for_the_String] = {"Your Name"};
String firstName = "Your Name";

//Second part that needs to be REPLACED:
System.out.printf("Your_name_here can code in Java!");

With this line:

System.out.printf("%s can code in Java!", firstName); //Replace with this one

For the last part you need to use the 'printf' (formatted text) properties as you have seen in the videos, just put the '%s' where you want to write you name and then that %s will be converted into the variable you passed it after the "comma" where it says 'firstName'

Hope this works for you.

M.