Skip to content

Instantly share code, notes, and snippets.

@maartenl
Created June 26, 2013 07:52
How to access things in your outer class from your inner class.
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