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 trialAlberry Rivera
Courses Plus Student 708 Pointspublic class Introductions error error 1 illegal start of expression
Why am i getting this error i tried this code in workspace with import java.io.console and it works fine but this right here doesn't
// I have imported java.io.Console for you. It is a variable called console
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
String firstName = console.readLine("What is your name? ");
console.printf("Hi, %s welcome to DineOUT\n", firstname);
console.printf("You can access the food in the menu %s\n", firstname);
}
}
1 Answer
Ken Alger
Treehouse TeacherAlberry;
Welcome to Treehouse!
For the challenge you don't need to create a class or do anything that isn't being asked in the instructions. So, if it requests to read in some data with console.readLine
, that is all you have to do.
Also, you are defining your variable as firstName
and calling it with the string formatter as firstname
. Variables in Java are case sensitive.
Happy coding,
Ken
Ken Alger
Treehouse TeacherKen Alger
Treehouse TeacherAlso, if you notice in the comments for the code challenge, a console has already been imported so we don't have to redo that.
Alberry Rivera
Courses Plus Student 708 PointsAlberry Rivera
Courses Plus Student 708 PointsThank you so much for the help :)