Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Basics Getting Started with Java IO

chase singhofen
chase singhofen
3,811 Points

console.printf("Last name: %s", lastName);

i cant figure out why this cant compile??

i need to print my last name string variable. previous question is same except for print last name instead of first name.thx

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
// I have imported java.io.Console for you.  It is a variable called console.

String firstName = console.readLine();
String lastName = console.readLine();

console.printf("Last name: %s", lastName);

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,624 Points

Hi Chase,

Well, your code is correct, except the code for Task 3 seems to have been deleted?

When working in code challenges, unless explicitly told otherwise by the Task's instructions, all subsequent code for tasks must be added to what you have inputed from previous tasks.

So, just put back in the code from Task 3, and add the code for Task 4 under the previous code, and it will all pass.

Keep Coding! :)
:dizzy:

chase singhofen
chase singhofen
3,811 Points

Thx. I finally got passed it. I'm very unfamiliar with workspace. I've been practicing in NetBeans and eclipse for 6 months or so.