Home static method does not run it in main class
Reply: 0

static method does not run it in main class

user1239
1#
user1239 Published in April 25, 2018, 12:42 am

Console prints illegal start of expression. Method is for finding letters in input String. Is it different when the method is under main or above it? Could netBeans cause the issue?

  package wars;

 public class Wars {

static String printerError(String s) {
    int a = 0;
    for (int i = 0; i < s.length(); i++) {
        if (!s.substring(i, i + 1).equals("a")
                || !s.substring(i, i + 1).equals("b")
                || !s.substring(i, i + 1).equals("c")
                || !s.substring(i, i + 1).equals("d")
                || !s.substring(i, i + 1).equals("e")
                || !s.substring(i, i + 1).equals("f")
                || !s.substring(i, i + 1).equals("g")
                || !s.substring(i, i + 1).equals("h")
                || !s.substring(i, i + 1).equals("i")
                || !s.substring(i, i + 1).equals("j")
                || !s.substring(i, i + 1).equals("k")
                || !s.substring(i, i + 1).equals("l")
                || !s.substring(i, i + 1).equals("m")) {
            a++;
        }
    }
    return a + "/" + s.length();
}

public static void main(String[] args) {

    System.out.println(Wars.printerError("pokemon"));
}

}

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.306834 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO