Whats the meaning of doing (MyApp)?
It is a reference type cast.
It checks that the reference produced by evaluating the RHS (i.e. this.getContext()
) is compatible with MyApp
and then uses it that as the result of the expression (with that type). If the reference given by the RHS expression is not for a compatible type, a runtime exception will be thrown.
By contrast ...
baseApp = myApp.doSomething();
is just calling the doSomething()
method and assigning it ... WITHOUT doing a typecast. If the doSomething()
method does not deliver a value of the correct type, you will get a compilation error.
For the record, there is no "instantiation" going on here. Instantiation is done using the new
operator1.
1 - ... or by calling specific reflective methods.