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

Even the code is correct its bumming up with error

import java.io.Console;

public class Introductions {

public static void main(String[] args) {
    Console console = System.console();
    // Welcome to the Introductions program!  Your code goes below here
    String firstName = console.readLine("What is your name ");
    console.printf("Hello my name is %s\n", firstName);
    console.printf ("%s learning Java\n", firstName);

} }

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

import java.io.Console;

public class Introductions {

    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
        String firstName = console.readLine("What is your name? ");
        console.printf("Hello my name is %s\n", firstName);
        console.printf ("%s learning Java\n", firstName);
  }
}

5 Answers

Hi there,

The challenge asks you to Declare a variable that is named the camel-cased version of "first name". Store the user's first name into this new variable using console.readLine. Do just that - no need for any other code. Just one line reading user input and storing it in a named variable.

Make sense?

Steve.

Then add the next tasks to the first task code - don't overwrite anything unless the instructions ask you to. Here, you create another variable for the last name then do some outputting with printf.

Still not

Post your code - let's figure out what's wrong.

Steve.

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

import java.io.Console;

public class Introductions {

    public static void main(String[] args) {
        Console console = System.console();
        // Welcome to the Introductions program!  Your code goes below here
        String camel-cased = console.readLine("Nithin");
        console.printf("Hello my name is %s\n", camel-cased);
        console.printf ("%s learning Java\n", camel-cased);
        console.printf("End");
  }
}

Hi Nithin,

I'll go back to my initial answer - you're doing too much code!

You have a console object provided and you're being asked to create a variable which is called the camel case version of 'first name' - that would look like firstName.

You want to assign a value into it by reading user input; you've got that bit, sort of. You could use console.readLine("What is your first name?: ");

Putting all that together, you get:

String firstName = console.readLine("What is your first name?: ");

That's task one done.

Make sense?

Steve.

yes thanks

Cool - good luck with the next tasks! :+1: