Last active
July 11, 2022 06:31
-
-
Save vinimonteiro/1443b3cb2c9b974a20ea21f915b5b5bf to your computer and use it in GitHub Desktop.
Inner Class Shadowing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.vinimo; | |
public class OuterClass { | |
public int age = 30; | |
class InnerClass { | |
public int age = 20; | |
void methodInInnerClass(int age) { | |
System.out.println("age = " + age); | |
System.out.println("this.age = " + this.age); | |
System.out.println("OuterClass.this.age = " + OuterClass.this.age); | |
} | |
} | |
public static void main(String[] args) { | |
OuterClass st = new OuterClass(); | |
OuterClass.InnerClass fl = st.new InnerClass(); | |
fl.methodInInnerClass(37); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment