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

it says illegal start of expression. What am I doing wrong?

public class Name { There is an arrow pointing to the word "public" but I don't know what I've done wrong.

Name.java
public class Name {

  public static void main(Strings[] args) {
       Console console = system.console();
    string firstName = "Sabrina";
    console.printf ("Hello, my name is %s.\n ", firstName);
    console.printf (" %s is a lovely name. \n ", firstName);
  }
}

4 Answers

Hi Sabrina Khan,

When it says // I have setup a java.io.Console object for you named console in code challenges, you don't need:

Example.java
public class Name {

  public static void main(Strings[] args) {
       Console console = System.console();
}
  }

I took that all out and received "JavaTester.java:94: error: class, interface, or enum expected" as a continuous error

nope! youre right! I deleted the first expressions and capitalized "String"

Always happy to help!

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

I donΒ΄t know why you have an error here, but i found that you have a typo here

Console console = system.console();
string = "Sabrina";

I think System and String must be uppercase Console console = System.console(); String = "Sabrina";

Java is case sensitive ....

Shout out if i am wrong and how you fugured it out :)

Emily Cain
Emily Cain
5,850 Points

Hi Sabrina,

Try changing "public class Name {" to "class Name {" i.e. removing the initial "public."

Hope this helps!

Emily

Johan Delgado
Johan Delgado
5,484 Points

Neither of those help were useful I am having the same issue and could not solve it I am stuck in this question, if there is a better answer please I will do appreciate it.

try deleting the first expressions and capitalizing the right words