Look at these lines in your example:
new Arithmetic(s);
boolean balanced = Arithmetic.isBalanced();
The first line creates an object. It uses the class Arithmetic and invokes the constructor that takes a string. Then, since no variable gets assigned the result, the new object gets thrown away.
The second line tries to call isBalanced. But (because it isn't declared with static
) isBalanced is an instance method, that means it needs to be called on an instance of Arithmetic. You made an object that you could call isBalanced on in the previous line, you just need to keep a reference to it, and use that reference.
Assign the new object to a variable:
Arithmetic a = new Arithmetic(s);
boolean balanced = a.isBalanced();