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 trialAmir Tamim
8,597 PointsCould someone please tell me why the code will not go through?
It says illegal expression for the first line.
// I have setup a java.io.Console object for you named
public class Name{
public static void main(String args[]){
String firstName= "Amir";
Console console= System.console();
console.printf("My name is %s\n", firstName);
}
}
5 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHi Amir,
Basically you went way beyond what the challenge is asking for. Instructions are very specific and must be followed explicitly, or the result will be a Bummer!
.
If you notice the comment, the console object has been created for you behind the scenes, so for Task 1, you should only have one line of code as the instructions just want you to assign your name to the variable. You do have the correct line of code, you just need to delete everything else and just keep
String firstName= "Amir";
Remember, instructions need to be followed exactly. So for Task 2, make sure the string is exactly what the instructions want.
Keep Coding! :)
sandro mirijanashvili
2,686 Pointsimport java.io.Console;
// I have setup a java.io.Console object for you named class Name{
public static void main(String args[]){ String firstName= "Amir"; Console console= System.console(); console.printf("My name is %s\n", firstName);
}
}
ps. this code will work. I imported Console and also class Name doesn't need to be public.
Jason Anders
Treehouse Moderator 145,860 PointsActually sandro mirijanashvili,
The above code is not correct and will produce a Compiler Error
in the challenge. Please see my answer to Amir below.
sandro mirijanashvili
2,686 Pointsactually i don't have membership and can't see it in treehouse I wrote in notepad++ and got a correct output .
sandro mirijanashvili
2,686 PointsName.java
sandro mirijanashvili
2,686 PointsAmir Tamim Jason Anders please tell me how to post pictures like you. thanks!
Jason Anders
Treehouse Moderator 145,860 PointsIt's not a picture. It is a code block inserted using Markdown. You can refer to the Markdown CheatSheet above the "Post Comment" button, or take the new Treehouse course on Markdown Basics. Code should always been formatted with markdown when posting to the Community, otherwise it is very unreadable.
sandro mirijanashvili
2,686 Points''' import java.io.Console; '''
sandro mirijanashvili
2,686 Pointssandro mirijanashvili
2,686 Pointscould you please tell me how do you upload this picture here ?
Amir Tamim
8,597 PointsAmir Tamim
8,597 PointsOh got it! Thanks for the help everyone! Much appreciated.
sandro mirijanashvili
2,686 Pointssandro mirijanashvili
2,686 Pointsthanks