| Introduction to OOP | Chapter 16: Overriding : | next | previous | audio | real | text |
class Silly {
private int x; // an instance variable named x
public void example (int x) { // x shadows instance variable
int a = x+1;
while (a > 3) {
int x = 1; // local variable shadows parameter
a = a - x;
}
}
}
Shadowing can be resolved at compile time, does not require any run-time search.