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

Define string variable firstName

Hi there,

Context: This is my first exercise. I have no coding experience and am running into my first problem.

Question: Attached you'll see the code I wrote for this exercise which asks me to define a string that asks me for firstName. Was there a certain set of lines I was supposed to write before writing out the string? Where can I look to find out how to set my code up for success starting from the very first line?

Thanks! Ayleen

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


{   
  String firstName = "Ayleen";

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

}

1 Answer

A way you can set your code up for success is always plan your project out. Planning reduces the amount of errors you may encounter from coding off the cuff. Once you plan out your project it is really easy to code because you have instructions to follow. It may not seem easy now to code some things, but it will. If you ever need help or don't understand something a good place to figure it out is the javadocs: https://docs.oracle.com/javase/8/docs/api/

If you are wondering why it isn't passing you don't need to surround your code with {}, at least not in this quiz. Also you need the message to say "<YOUR NAME> can code in Java!"