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 trialDmitriev Denis
1,281 PointsI do not understand what in this task is demanded from me? I made everything as I saw in the video.
I tried delete some parts or add some parts but it stoill does not work. Can anybody explan me what wrong here please?
// I have setup a java.io.Console object for you named consolepublic static void main(String[] args) {
public static void main(String[] args) {
String firstName="denis";
console printf("Hello, my name is %s\n" firstName);
console.printf("%s is learning how to write Java\n" firstName);
}
1 Answer
Jason Anders
Treehouse Moderator 145,860 PointsHey Dmitriev,
You're on the right track, but there are a few things going wrong here.
- First, you said you added some code. Unless the instructions explicitly say to... don't, as it will cause errors. Here you added the
public static void
method, when the code already said that it has it created for you (behind the scenes). Here it will be best to restart the challenge to reset to the original preloaded code. - So, the first task asks for your name in a string, which is correct, and Task 2 asks you to write out
"<YOUR NAME> can code in Java!"
, but you are using"%s is learning how to write Java\n"
. These do not match. The string needs to read "can code in Java!" but you are writing "is learning to write Java". Also, the challenge does not ask for a new line, so\n
should not be there either. - You are missing the comma needed to attach the variable to the string to be inserted into the place holder.
The correct code for all three tasks will be only 2 lines of code. The string for your name is correct, and the last line you have there is pretty much correct... just fix up what the string says and add the comma.
Hope this helps. If you're still stuck, let us know and post the new code you are trying.
Keep Coding! :)