comments
This commit is contained in:
parent
68d4c9b733
commit
f5d5e87fa4
|
@ -5,7 +5,7 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="openjdk-22" jdkType="JavaSDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -5,7 +5,7 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="openjdk-22" jdkType="JavaSDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -5,7 +5,7 @@
|
|||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="openjdk-22" jdkType="JavaSDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -14,12 +14,18 @@ public class Main {
|
|||
// a.print(12, "there"); // Ok
|
||||
// a.print(88); // Compilation error
|
||||
|
||||
// IV
|
||||
// ClassA a = new ClassC(); // Ok
|
||||
// ClassG g = new (ClassG)a; // Syntax error
|
||||
// IV - We do not have access to a print(String) from the ref C, even though it was downcasted to the obj G
|
||||
// ObjectType <- ReferenceType
|
||||
// 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
|
||||
// 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
|
||||
// ClassG g = (ClassG)a; // ok
|
||||
// g.print("hello", "there"); // Runtime error: trick
|
||||
|
|
Loading…
Reference in New Issue