Java Java Objects Harnessing the Power of Objects Abstraction at Play

Lucas Easley
Lucas Easley
691 Points

java 21 error


I keep receiving a parsing error and after reviewing my code and I'm not sure why. I think it has something to do with the curly brackets. Please help!

''' 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 FACT: There are %d PEZ allowed 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, dickhead"); } System.out.println("Filling the dispenser with PEZ..."); dispenser.fill(); if(!dispenser.isEmpty()) { System.out.println("Dispenser is full"); }

} '''

1 Answer

Steven Parker
Steven Parker
203,137 Points

You're exactly right about the curly brackets. In "" they are out of balance, and you need one more closing bracket at the end to restore the matched pairs.

Also, for code formatting, you need 3 backticks (```), not apostrophes (''').