0
Why I dont get the desired result? if-else statement
Hello to evryone. Could anyone explain me why I dont get the output "error" when my "age" is minus 5. Thanks in advance. int age = -5; if(age > 0) { if(age > 16) { System.out.println("Ok"); } if(age >100) {System.out.println("Realy"); } if(age <16) {System.out.println("Forbidden"); } else { System.out.println("error"); }
1 Answer
0
Actually you have missed something.
Put another curly brace before beginning of else statement, that would fix it.