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

Tiago Santos
PLUS
Tiago Santos
Courses Plus Student 38 Points

I trying to finish this exercise but I am getting some errors that I dont know how to fix.

JavaTester.java:73: error: illegal start of expression import java.io.Console; ^ JavaTester.java:73: error: not a statement import java.io.Console; ^ JavaTester.java:75: error: illegal start of expression public class Name { ^ 3 errors

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

public class Name {

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

        // Welcome to the Introductions program!  Your code goes below here

      String firstName = "Tiago";

      console.printf("My name is %s/n, firstName");

  }
}

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

i can't tell if you linked the same challenge you are asking about or not, but you don't need a main in this one, just the variable holding your name, type that you can code in java, then in task 3 you type the same thing but use string formatting (%s) to insert your name with the variable. when you use string formatting, the variable goes outside of the quotes of the string.