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

These questions never want to let me move on, they´re so picky and specific

It says for me to put a string variable named firstName equal to my first name, which I did, but apparently that´s not my name anymore. Here´s the code I put, the only error is the silly variable. Any help?

class MyProgram { public void main(String args[]) { String firstName="joseph"; System.out.println(firstName); } }

Name.java
class myProgram
{
  public void main(String[] args)
  {
  String firstName="Joseph";
  System.out.println(firstName);
  }
}

2 Answers

Just use this below, instead of typing the whole program.

String myName = "joseph";

Ah it worked, thanks a lot! I was trying to put the whole code in lol.

Your code is good, just missing two keywords. Add public to the class myProgram like

public class myProgram

and you need to add the keyword static to the main function like

public static void main(String[] args)

Doing both of those created its own error. That´s why static and public aren´t there. Now, the only error left isn´t an error found in the compiler, but on the site or I´m not sure how to put it. It says for me to put my name, which I did...