Esoy doing a stack balancing program, I run the program but nothing happens, the execution time is 0 seconds, could you tell me what I'm wrong? This is the code:
package bracket.checker;
import java.util.Stack;
/**
*
* @author Usuario
*/
public class BracketChecker {
private String expresion;
public BracketChecker(String e){
this.expresion=e;
}
public boolean esValido(){
Stack pila =new Stack();
for(int i = 0; i<expresion.length();i++){
if(expresion.charAt(i)=='('){
pila.push('(');
}
if(expresion.charAt(i)== ')'){
if(pila.empty() ){
pila.push(')');
}else{
pila.pop();
}
}
if(expresion.charAt(i)=='{'){
pila.push('{');
}
if(expresion.charAt(i)== '}'){
if(pila.empty() ){
pila.push('}');
}else{
pila.pop();
}
}
if(expresion.charAt(i)=='['){
pila.push('[');
}
if(expresion.charAt(i)== '['){
if(pila.empty() ){
pila.push('[');
}else{
pila.pop();
}
}
}
if(pila.empty()){
return true;
}
return false;
}
public static void main(String[] args) {
// TODO code application logic here
String e1= "{([])}";
String e2= "(][])";
String e3= "[]{()}";
BracketChecker parentesis = new BracketChecker(e1);
parentesis.esValido();
}
}