comments
This commit is contained in:
parent
68d4c9b733
commit
f5d5e87fa4
|
@ -5,7 +5,7 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="openjdk-22" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -5,7 +5,7 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="openjdk-22" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -5,7 +5,7 @@
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="openjdk-22" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -14,12 +14,18 @@ public class Main {
|
||||||
// a.print(12, "there"); // Ok
|
// a.print(12, "there"); // Ok
|
||||||
// a.print(88); // Compilation error
|
// a.print(88); // Compilation error
|
||||||
|
|
||||||
// IV
|
// IV - We do not have access to a print(String) from the ref C, even though it was downcasted to the obj G
|
||||||
// ClassA a = new ClassC(); // Ok
|
// ObjectType <- ReferenceType
|
||||||
// ClassG g = new (ClassG)a; // Syntax error
|
// Compiler always keep tracking of ObjectType
|
||||||
|
// While only during Runtime that we will check and execute the ReferenceType
|
||||||
|
// ClassA a = new ClassC(); // Ok -> Upcast A<-C
|
||||||
|
// ClassG g = (ClassG)a; // Ok -> Downcast G<-(A<-C)
|
||||||
// g.print("hello"); // RunTime error: trick
|
// g.print("hello"); // RunTime error: trick
|
||||||
|
// Upcast is prone to Compiler error
|
||||||
|
// Downcast is prone to Runtime error
|
||||||
|
|
||||||
// V
|
|
||||||
|
// V - We lost track of the print(string, string) in C become it become a A first
|
||||||
// ClassA a = new ClassC(); // ok
|
// ClassA a = new ClassC(); // ok
|
||||||
// ClassG g = (ClassG)a; // ok
|
// ClassG g = (ClassG)a; // ok
|
||||||
// g.print("hello", "there"); // Runtime error: trick
|
// g.print("hello", "there"); // Runtime error: trick
|
||||||
|
|
Loading…
Reference in New Issue