steve hitch

Greenhorn
+ Follow
since Jun 01, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by steve hitch

Question 235, as stated, is not correct. It reads:
(#235) TRUE or FALSE: a static inner class (considered a
top-level nested class) can NOT access non-static variables
of the outer class.
The desired answer is TRUE, but in practice, is false.
The following code shows how, with Outer being the outer
class, three being the non-static variable, and Inner
being the static inner class:
public class Outer {
protected static Outer self = null;
protected int three = 3;
public Outer() {
self = this;
Inner.doIt();
}
protected static class Inner {
protected static void doIt() {
if (Outer.self != null) {
System.out.println(Outer.self.three);
}
}
}
}
23 years ago