I've become a great fan of your questions. The most interesting part is that you finish the post by giving references to places where we get a decent explanation for that particular question you post. Great job man.
Regards, Jothi Shankar Kumar. S [ October 31, 2006: Message edited by: Jothi Shankar Kumar Sankararaj ]
Prahalad Deshpande
Greenhorn
Joined: Oct 31, 2006
Posts: 14
posted
0
The code will print Hello because of the semi colon after the "if". Then it will print world.
Vivian Josh
Ranch Hand
Joined: Oct 31, 2006
Posts: 112
posted
0
------------------------------- public class Main { public static void main(String[] args) { boolean x = true; if (x = isOn()); { System.out.println("Hello"); } System.out.println("World"); }
public static boolean isOn() { return false; } } ----------------------------------- Bcoz of the semicolon, it will print Hello and then on next line will print World .
Hello World
Prasanth Pillai
Ranch Hand
Joined: Oct 16, 2006
Posts: 52
posted
0
Hello World
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
posted
0
Alright, you nailed it! Good job!
The catch here was of course the semicolon and to a lesser extent the assignment operation in the if condition.