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 trialaden ajayi
552 PointsExample.java:21: error: reached end of file while parsing
Not sure all my braces seem to be in the right place but i keep getting Example.java:21: error: reached end of file while parsing
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 ("Hisoka"); { System.out.printf ("the Dispenser is %s %n", dispenser.getCharacterName() ); } if (dispenser.isEmpty()) { System.out.println ("Dispenser is empty"); } System.out.println("Filling the despenser with the good stuff..."); dispenser.fill(); if (!dispenser.isEmpty()){ System.out.println("Dispenser is full"); }
}
4 Answers
adsdev
15,583 PointsYou're very very close ! I've put the code in a Java format so you can read it back. Very carefully re-examine this code and see where you went wrong. You are on the right track. It has to do with curly braces.
Small hint below. Look at the structure with the curly braces.
if (condition) {
//Do something... Like
System.out.println ("Some challenge with dispensers");
}
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 ("Hisoka");
{ System.out.printf ("the Dispenser is %s %n", dispenser.getCharacterName() ); }
if (dispenser.isEmpty()) { System.out.println ("Dispenser is empty"); }
System.out.println("Filling the despenser with the good stuff...");
dispenser.fill();
if (!dispenser.isEmpty()){
System.out.println("Dispenser is full");
}
}
If you need more help, do ask :) !
Anthony Abelardo
754 Pointspublic class Example {
public static void main(String[] args) {
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"); }
System.out.println("Filling the dispenser with delicious PEZ..");
dispenser.fill();
if (!dispenser.isEmpty() )
{ System.out.println("Dispenser is full"); }
} }
I've made the setup look cleaner so it can be easier for me to read in future lessons. I think I was missing a bracket or something.
Anthony Abelardo
754 Points{ public class Example {
public static void main(String[] args) {
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"); }
System.out.println("Filling the dispenser with delicious PEZ..");
dispenser.fill();
if (!dispenser.isEmpty() )
{ System.out.println("Dispenser is full"); }
} } }
Anthony Abelardo
754 PointsHow do I delete the comments?
aden ajayi
552 Pointsaden ajayi
552 PointsI still don't see whats wrong am I missing a curly brace is it in the wrong place?
adsdev
15,583 Pointsadsdev
15,583 Pointsaden ajayi I really don't want to give it away. But yes it is in that direction :) This part of figuring out whats wrong will really help you in the future.