// If the current character is a closing bracket. if (map.containsKey(c)) {
// Get the top element of the stack. If the stack is empty, set a dummy value of '#' chartopElement= stack.empty() ? '#' : stack.pop();
// If the mapping for this bracket doesn't match the stack's top element, return false. if (topElement != map.get(c)) { returnfalse; } } else { // If it was an opening bracket, push to the stack. stack.push(c); }