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

error keeps being thrown. Whats wrong? JavaTester.java:73: error: illegal start of expression public

JavaTester.java:73: error: illegal start of expression public class Introductions{ ^ 1 error

Name.java
public class Introductions{
  //error code throwing here for above line
    public static void main(String[]args){
    Console console = System.console();
    String firstName= "Veronica";
    console.printf("Hello, my name is %s\n,firstName");
    console.printf("%s is learning how to write Java\n, firstName");
  }
}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi Veronica! There are a couple of problems here and mostly to do with following the instructions of the challenge, but also to do with your printing out of strings. Keep in mind going forward through these challenges to try not to do anything not explicitly asked for by the challenge. Even if functional, it can cause the challenge to fail.

  • The challenge does not ask you to define a class
  • The challenge does not ask you to include a main function
  • The above two notes are done on their side for you so they may evaluate your code
  • The challenge has already set up a console variable for you as noted by the comments in step 1

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

  • The first step of the challenge does not ask you to print anything.
  • The next steps of the challenge ask you to print out a different string.
  • The quotation marks are incorrectly placed in your console.printf. The end quote should come before the comma.

For example: console.printf("Hi there! My name is %s.", firstName);

I hope these hints help, but let me know if you're still stuck! :sparkles:

Jennifer, that worked! Thanks so much!