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

afra raheem
seal-mask
.a{fill-rule:evenodd;}techdegree
afra raheem
Front End Web Development Techdegree Student 38 Points

Define a String variable Name

what is wrong in my code????

Name.java
public class Name{
  public static void main(String[] args);
   String firstName = "Afra";
  console.printf("firstName");
}
}
Keli'i Martin
Keli'i Martin
8,227 Points

Are you working on Task 3 of the challenge?

5 Answers

Ryan Chatterton
Ryan Chatterton
5,914 Points

afra raheem what step are you on?

step 1 you just need to define your name

String firstName = "bob";

step 2 they want you to print it out with the message

String firstName = "bob";
console.printf("<YOUR NAME> can code in Java!");

Step 3 is the replace

String firstName = "bob";
console.printf(String.format("%s can code in Java!", firstName));

you don't need the class , or the main method for the challenge.

Ryan Chatterton
Ryan Chatterton
5,914 Points

Try: You had a ; after the method and missing a {

public class Name {
  public static void main(String[] args)  {
       String firstName = "Afra";
      console.printf("firstName");
    }
}
afra raheem
seal-mask
.a{fill-rule:evenodd;}techdegree
afra raheem
Front End Web Development Techdegree Student 38 Points

JavaTester.java:72: error: illegal start of expression public class Name { ^ 1 error how to solve this error??? plz help me anybody

Keli'i Martin
Keli'i Martin
8,227 Points

Can you post your updated code?