(I really don't know how to phrase the question any better. I'm sure there is a concept involved here that I'm unaware of, so please suggest a better phrasing if you can--or direct me to an answered question if this turns out to be a duplicate)
I've been playing around in Java and found some behavior I can't explain. In the following code, I'd expect a 0
to be printed. However, nothing is printed. The only possible explanation I can come up with is that the main method ends before the printstream is flushed, but it doesn't make sense to me why that might be. In short, whats up with this code printing nothing instead of 0
?
class Test {
public static void main (String [] args) {
if(false && method()){
}
}
public static boolean method(){
System.out.println(0);
return true;
}
}