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

what is wrong with this java hello world ?

public class test{

     public static void main(string[] args){
     String userInput= console.readLine('What is your name? ');
     console.printf('Hello %s I am your first program', userInput);


            }

}

test.java:5: error: not a statement
console.printf('Hello %s I am your first java program', userInput);
^
test.java:5: error: ';' expected
console.printf('Hello %s I am your first java program', userInput);
^
17 errors

2 Answers

Do not use ' ', for Strings you need to use quotes " ". Single quotes ' ' are for chars.

Also, this is unrelated to your actual question, but, it is common java naming convention to always capitalize the first letter of your class name.

yep, also need "String[] args" in the method signature.

Haha I didn't catch the lowercase 's', nice one!

Thanks guys!!