Don't know why it's not working


#1

import java.lang.;
import java.util.
;
import java.util.Stack;

public class Main {
public static void main(String[] args) {
String s = “(()())”;

    int i = 0; 
    Stack<Character> st = new Stack<>(); 
    
    while(s.length() > 0) 
    {
        char ch = s.charAt(i); 
        
        if(ch == ')' && st.peek() == '(') 
        {
            st.pop(); 
        }
        else if(ch == '(') 
        {
            st.push(ch);
        }
        
        i++; 
    }
    
    if(st.size() == 0)  
    {
        System.out.println("1"); 
    }
    else 
    {
         System.out.println("0");  
    }
}

}