public class MainClass { public static void main(String[] argv) { System.out.println(test(null, 1)); System.out.println(test("a", 0)); System.out.println(test("NO", 2)); System.out.println(test("YES", 1)); } public static int test(String x, int n) { if (n == 0) return n; else if (n == 1) { if (x != null) return 5; } else if (n == 2 && x != null) { if (x.equals("YES")) return 3; else if (x.equals("NO")) return 4; } return -1; } }