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 trialM G
101 Pointshelp with printf and firstName
pls hlp
// I have setup a java.io.Console object for you named console
String firstName = ("Mark");
console.printf = String firstName;
cosole.prinf("my name is %s\n");
2 Answers
Dean Silvestro
Courses Plus Student 20,733 PointsOk let's start with your first line. It works, but you don't really need the parentheses around your name.
Now for the second step of the challenge you need to use the printf method on the console object and "YOUR NAME can code in Java!" as the parameter. You almost have that in your third line.
For step three you need to replace YOUR NAME with %s and then follow that up with a second parameter which would be the String you set up in the first step of the challenge.
The final product should look something like this:
console.printf("%s can code in Java!", firstName);
Ariel Espinal
5,451 PointsLike Thomas said, only use parenthesis when you are about to enter an argument to an object. Since your declaring firstName as a "string" you only need to use "".
The second line of your code you already declared firstName as a String, so i believe you only need to declare it to your firstName variable.
In your last line, you have typos.
Hope this helps.