I am doing Android programming and was learning about Intents, when I saw a constructor that, to my C# trained mind, seemed funky. The call was:
Intent myI
.this
is used in nested classes to refer to the current instance of the enclosing class, since the `this' keyword refers to the nest class instance.
public class Siht { class NestedSiht { void demoThis() { System.err.println("this' is an instance of: " + this.getClass().getName()); System.err.println("
Siht.this' is an instance of: " + Siht.this.getClass().getName()); } }void demoThis() { new java.lang.Object() { void demoThis() { System.err.println("`this' is an instance of: " + this.getClass().getName()); System.err.println("`Siht.this' is an instance of: " + Siht.this.getClass().getName()); } }.demoThis(); new NestedSiht().demoThis(); } public static void main(String [] args) { new Siht().demoThis(); }
}