You really should read a tutorial about exceptions and work it through completely. This way you will get a better understanding of exceptions.
Your problem is the method Matching.matching()
. You are using the methods ArrayStack.push(Object)
and ArrayStack.topAndpop()
in the method's implementation. But these methods are declared to (potentially) throw an EmptyStackException
.
Your matching
method does not deal with that exception. The exception must be either caught or thrown. This is what the compiler does tell you. So for a first coming-through declare the method as
public boolean matching() throws EmptyStackException