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 trialkartheek lingutla
53 Pointsillegal start of expression??
I am getting below error while compiling the program. I am not sure what mistake I am doing here. I have double checked the class notes and written the code. Could you please correct me on the below issue. Thanks
JavaTester.java:128: error: illegal start of expression public class IO { ^ 1 error
// I have imported java.io.Console for you. It is a variable called console.
public class IO {
public static void main (String[] args)
{
Console console = System.console();
String firstName = console.readLine("My name is");
console.printf("Hello, my name is %s\n", firstName);
console.printf("%s is learning java\n",firstName);
}
}
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHi kartheek,
If you're on the first task, then you've gone way beyond what the task is asking for. The first task simply asks
Declare a variable that is named the camel-cased version of "first name". Store the user's first name into this new variable using console.readLine.
So, you have the answer, it's just buried in code that was not asked for by the instructions. Challenges are very specific and very picky, so if you add more than what is asked for it will not pass.
If you 'un-complicate' your answer, it will pass. All that is needed (and asked for in Task one) is
String firstName = console.readLine("My name is");
That's it... Just remember to keep things simple.
Keep Coding!