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 trialEdrin Thomas
96 Pointserror in code
Import java.io.Console; i keep getting error for this statement. can u explain?
// I have imported java.io.Console for you. It is a variable called console.
Import java.io.Console;
public class IO
{
public static void main(string[]args)
{
Console Console=system.Console();
string first name=Console.readline("what is ur name? ");
}
}
3 Answers
ISAIAH S
1,409 PointsIt says that it has already imported it for you, so you don't need that line. Also, he said it was called console
not 'Console'.
Delete:
Console console = system.Console();
And change 'Console' to console
and you should be good.
Yongshuo Wang
5,500 PointsThere are a few problem with your code, see my code
// I have imported java.io.Console for you. It is a variable called console.
public class IO
{
public static void main(string[]args)
{
String firstName = console.readLine("what is ur name? ");
}
}
ISAIAH S
1,409 PointsHi Yongshuo Wang, Craig wants firstName
to write out 'First name: ' and 'string' in
public static void main(string[]args) {
should be capitalized.
Yongshuo Wang
5,500 PointsHi, first the string should be String.
What Craig means like this:
String firstName = console.readLine("First Name: ");
Hope it can help.