| Author |
initialization error
|
Harvinder Singh
Ranch Hand
Joined: Feb 14, 2003
Posts: 90
|
|
//even when the y is declared outside compiler says that value of y is unassigned.Is this error is because y is a local variable of main() method or is there any other reason.thanks. public class Compare2{ public static void main(String args[]) { int x = 10, y; System.out.println("y is " + y); } }
|
Hard work beats talent<br />when talent doesn't work hard.<p> - Tim Notke
|
 |
Munish Gulati
Ranch Hand
Joined: Aug 06, 2003
Posts: 37
|
|
|
Yes you are right, local variables are to be initialized explicitly.
|
Munish Gulati<br />SCJP 1.4<br />Albert Einstein: There are only two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle.
|
 |
 |
|
|
subject: initialization error
|
|
|