Skip to content

Commit c554346

Browse files
committed
Example of Shadowing
1 parent 5a2db0e commit c554346

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/Functions/Shadowing.java‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package Functions;
2+
/*
3+
Shadowing is a practice to use a variable with a same name in different methods
4+
* */
5+
6+
public class Shadowing {
7+
static int x = 90;
8+
public static void main(String[] args) {
9+
System.out.println(x);
10+
int x = 40;
11+
System.out.println(x);
12+
function();
13+
}
14+
15+
static void function(){
16+
System.out.println(x);
17+
}
18+
}

0 commit comments

Comments
 (0)