Java Spec 16 Definite Assignment
Each local variable ... must have a definitely assigned value when any access of its value occurs.
14.4.2 Scope of Local Variable Declarations
"causes a compile-time error because the initialization of x is within the scope of the declaration of x as a local variable, and the local x does not yet have a value and cannot be used."
The same result will be even without static declaration like :
class Scope {
public static void main(String[]) {
int myint = myint;
System.out.println(myint);
}
}
D local variable myint is not initialized , u can use int myint = this.myint to reference the class variable myint
upvoted 3 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
06d854e
4 months agoASPushkin
5 months, 1 week agotmuralimanohar
1 year, 6 months agoStavok
1 year, 7 months agoMukes877
1 year, 7 months agoRP384
1 year, 11 months agoAnkit1010
1 year, 11 months agoTADIEWA
2 years ago