Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects Harnessing the Power of Objects Exceptions

victor medina
victor medina
540 Points

Example.java:34: error: cannot find symbol. need help were is the error.

public class Example {

  public static void main(String[] args) {
    // Your amazing code goes here...
   System.out.println("We are making a new PEZ Dispenser"); 
    System.out.printf("FUN FATCT: There are %d PEZ alloud in every dispenser %n",
    PezDispenser dispenser = new PezDispenser("Yoda");
     System.out.printf("The dispenser is %s %n",
    if (dispenser.isEmpty()){
      System.out.println("Dispenser is Empty");
    System.out.println("Filling the dispenser with delicious Pez...");
    if (!dispenser.isEmpty()){
      System.out.println("Dispenser is full");
    while (dispenser.dispense()) {
     System.out.println("Ate al the PEZ"); 
    while (dispenser.dispense()){
    try { 
    System.out.println("This will never happen");
  } catch (IllegalArgumentExeption iae) {
    System.out.println("whoa there!");
    System.out.println("The error was %s",

1 Answer

Lena Hand
Lena Hand
Courses Plus Student 1,575 Points

You're using a formatting symbol (%s) with a println statment. You need to use printf.

System.out.printf("The error was %s", iae.getMessage());