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 Objects (Retired) Meet Objects Privacy and Methods

Mehran Hasmati
Mehran Hasmati
2,489 Points

What did I get wrong?

I keep on getting a error. This is my Example.java

public class Example {

    public static void main(String[] args) {
        // Your amazing code goes here...
      System.out.println("We are a making a new Pez Dispenser.");
      PezDispenser dispenser = new PezDispenser();
      System.out.printf("The dispenser character is %s\n,
                        dispenser.getCharacterName());
    }
}

and this is my PizDispenser.java

public class PezDispenser {
  private String mCharacterName = "Yoda";

  public String getCharacterName() {
    return mCharacterName;
  }
}

I don't know what i am doing wrong.

1 Answer

Nicholas Grenwalt
Nicholas Grenwalt
46,626 Points

Simple fix. You just need a double quote (") after your \n in the System.out.println so that it knows that the string is done. Didn't test it, but that should do the trick from what I can see.