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 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.MAX_PEZ);
    PezDispenser dispenser = new PezDispenser("Yoda");
     System.out.printf("The dispenser is %s %n",
                      dispenser.getCharacterName()
                      );
    if (dispenser.isEmpty()){
      System.out.println("Dispenser is Empty");
    }
    System.out.println("Filling the dispenser with delicious Pez...");
    dispenser.fill();
    if (!dispenser.isEmpty()){
      System.out.println("Dispenser is full");
    }
    while (dispenser.dispense()) {
     System.out.println("Chomp"); 
    }
    if(dispenser.isEmpty()){
     System.out.println("Ate al the PEZ"); 
    }
    dispenser.fill(4);
    dispenser.fill(2);
    while (dispenser.dispense()){
     System.out.println("Chomp!!"); 
    }
    try { 
    dispenser.fill(400);
    System.out.println("This will never happen");
  } catch (IllegalArgumentExeption iae) {
    System.out.println("whoa there!");
    System.out.println("The error was %s",
                        iae.getMessage());   
    }
  }

1 Answer

Lena Hand
PLUS
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());