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 trialJames Fan
1,264 PointsJava question
String firstName="Fan"; console.printf("First name: %s", firstName); why still says i foget to pass firstName parameter in printf method?
// I have imported java.io.Console for you. It is a variable called console.
String firstName="Fan";
console.readLine("My firt name is "+firstName);
String lastName="James";
console.readLine("My name is " + firstName + " " +lastName);
console.printf("First name: %s", firstName);
2 Answers
K Cleveland
21,839 PointsString firstName="Fan";
console.readLine("My firt name is "+firstName);
Hey! The reason why your code isn't passing is because of how the questions are set up. This is what the task says:
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.
You declared a String firstName and set the string to "Fan". However, the task is asking you to declare a variable and then store the name using console.readLine.
If I wanted to store a string from console.readLine, I might write something like this:
String myVariable;
myVariable = console.readLine("This will get stored in myVariable");
Hope this helps! :)
James Fan
1,264 Pointsthanks! i found the answer in the forum the same problem people asked.
K Cleveland
21,839 PointsAwesome! Good luck!