Super Six Substrings

  • + 0 comments

    can anyone explain whats wrong with my code? public class superString {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            for (int j = 0; j <= s.length(); j++) {
                try {
                    // System.out.println(s.substring(i,j));
                    int k = Integer.valueOf(s.substring(i, j));
                    if (k==0) {
                        count++;
                    } else if ((s.substring(i, j).startsWith("0"))) {
                        count += 0;
                    } else {
    
                        if (k % 6 == 0) {
                            count += 1;
                        }
    
    
                    }
                }
    
                catch (Exception e) {
    
                }
            }
    
        }
        System.out.println(count);
    
    }
    

    }