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!

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


rojy mathew
rojy mathew
145 Points

code challenge:define a string variable


I couldnt find the syntax error. below is my code

public class Rojy { public static void main(String[] args) { Console console = System.console(); String firstname = "rojy"; console.printf("hi everyone im %s\n",firstname);



error recieved

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

2 Answers

Rojy, you didn't give a link to the challenge, so I can't see it there. When I put it in my IDE it compiles fine. So there are no syntax errors. It may be that you didn't do exactly what the challenge asked you to do. Challenges can be quick picky!!

If you include a link that would be a big help.

Rojy, you were doing much more than what the challenge asked for. You don't need a class, or to recreate the Console object. This will do fine:

String firstName = "Rojy";
console.printf("%s can code in Java!", firstName);