Hi Every one,
This is my first post in this site..
I am preparing for SCJP..planning to write within 10 days.
I saw this program in javaprepare.com site in language fundamentals questions..
I ran this program and it is not compiling..giving error as y may not be inetialised..
my thinking is..as in 2nd if stmt y is getting 2 It has to compile and run and display 2 for y..
I want help..please clarify my doubt..
public class Compare {
public static void main(
String args[]) {
int x = 10, y;
if(x < 10) <br /> y = 1;<br /> if(x>= 10) y = 2;
System.out.println("y is " + y);
}
}
Thanks in advance..
Regards
radhika