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!

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 Strings, Variables, and Formatting

Courses Plus Student 1,152 Points

define a string variable firstname

hi i am getting errors please help me.

// I have setup a java.io.Console object for you named console
public class Name{
  public static void main(Strings []args){
    Console console= System.console();
    String name="Ben";
    console.printf("hi i am %s\n",name);
    console.printf("%s is learning",name);
Jason Anders
Jason Anders
Treehouse Moderator 145,840 Points

Duplicate post(s) deleted from the Community. Please refrain from multiple posting for the same question

Jason ~Treehouse Community Moderator

2 Answers

You don't need to create a class and a main method. In this challenge, just write the lines that go inside the main method. As it says in the comments, you also shouldn't create a console object. There is already one and you can just use it.

For the first task just write the variable declaration. It should be a single line of code. Your variable should be called firstName, not name or anything else.

Task 2 should be a second line of code, which you then should change slightly for the third task. At no point should you have more than two lines of code. Just follow the instructions exactly and you'll be fine.

first thing I can see ... you write Strings ... with an "s" at the end ... but it is always String ... without the "s" ...

public static void main(String[] args) {