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 trial

Java

any help? String firstName = console.readLine("what is your name? "); it says I have an incompatible error

Console console = System.console();
// Welcome to the Introductions program!  Your code goes below here
String firstName = console.readLine("what is your name?  ");
// console print   
console.printf("Hello my name is %s\n", firstName);
console.printf("%s is learning how to write java\n", firstName);

String firstName = console.readline("what is your name? ");
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

1 Answer

Hey Billy,

Are you attempting the IO challenge or compiling this in workspaces/off-site?

Its in the io challenge

Okay, that makes sense. You don't need to declare or initialize a console object for the challenge. It's already there by default for you in that instance. That's why you're receiving an error.

Here's the complete code if you're stuck:

String firstName = console.readLine("What is your name?  ");
String lastName = console.readLine("What is your last name?  "); 
console.printf("First name: %s\n", firstName);
console.printf("Last name: %s\n", lastName);

Thanks I've been stuck for like an hour