public class Example8 {
public static void main(String[] args) {
System.out.println(check(null, 3));
System.out.println(check("hello", 7));
System.out.println(check("bye", 2));
System.out.println(check("hai", 3));
}
public static int check(String a, int n) {
if (n == 7)
return n;
else if (n == 3) {
if (a != null)
return 5;
} else if (n == 5 && a != null) {
if (a.equals("hai"))
return 3;
else if (a.equals("bye"))
return 4;
}
return -3;
}
}
(3)
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.