Created
June 26, 2013 07:52
How to access things in your outer class from your inner class.
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 mrbear; | |
/** | |
* | |
* @author MrBear | |
*/ | |
public class MrBear | |
{ | |
private String world = "The world."; | |
public class FirstInner | |
{ | |
public void printWorld() | |
{ | |
// ambiguous | |
System.out.println(world); | |
} | |
} | |
public class SecondInner | |
{ | |
public void printWorld() | |
{ | |
// not ambiguous | |
System.out.println(MrBear.this.world); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment