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 Java Basics Getting Started with Java IO

Barisan Firildak
Barisan Firildak
403 Points

why its not working?

I dont understand why this is not working

IO.java
// I have imported java.io.Console for you.  It is a variable called console.
public class Introductions {
  public static void main(String[] args) {
    Console console = System.console();
    String firstname = console.readLine("hey whats ur name?");
    console.printf("hey its barry %s\n", firstname);
    console.printf("%s yo whatsup \n", firstname);
  }
}

2 Answers

Manish Giri
Manish Giri
16,266 Points

Declare a variable that is named the camel-cased version of "first name"

I think your variable should be camelcased, so firstName. You have firstname.

Nicolas Curat
Nicolas Curat
2,995 Points

Hi Barisan, actually there are two problems!

First of all you don't have to create a class for the challenge, the already defined the variable console so you don't have to do it :). And the other problem, is that as a code convention in Java all the variables should be camel cased so instead of using firstname, you should use firstName.

So the challenge should be like this:

String firstName = console.readLine("hey whats ur name?");
console.printf("hey its barry %s\n", firstName);
console.printf("%s yo whatsup \n", firstName);