Java

Harshavardhan Gangavarapu
Harshavardhan Gangavarapu
9,703 Points

can't find error

class PezDispenser{ public static final int MAX_PEZ=12; final private String charecterName; private int pezCount;

public PezDispenser(String charecterName){ this.charecterName=charecterName; pezCount=0; } public void fill(){ fill(MAX_PEZ); }

public boolean dispense(){ boolean wasDispensed=false; if(!isEmpty()){ pezCount--; wasDispensed=true; } return wasDispensed; public boolean isEmpty(){ return pezCount==0; }

public String getCharecterName(){ return charecterName; }

public void fill(int pezAmount){ pezCount+=pezAmount; } } }

The error is:- Example.java:21: error: not a statement
t
^
Example.java:21: error: ';' expected
t
^
Example.java:32: error: reached end of file while parsing
}
^
3 errors

Please help me out

1 Answer

First of all, it should be:

private final String charecterName;

Not

final private String charecterName;

Next, I do not see a closing curly brace for your dispense() method.