I am trying to create a program that takes a string as an argument into its constructor. I need a method that checks whether the string is a balanced parenthesized expressio
Similar to one of the code above in JAVA but It needs one more else statement added in order to avoid stack comparison with characters other than braces :
else if(bracketPair.containsValue(strExpression.charAt(i)))
public boolean isBalanced(String strExpression){
Map bracketPair = new HashMap();
bracketPair.put('(', ')');
bracketPair.put('[', ']');
bracketPair.put('{', '}');
Stack stk = new Stack();
for(int i =0;i