Verified Commit 6fe28339 authored by Jonas Sulzer's avatar Jonas Sulzer 馃帗
Browse files

馃悰 FIX: type errors


Signed-off-by: Jonas Sulzer's avatarJonas Sulzer <jonas@violoncello.ch>
parent 94dc9d56
......@@ -9,15 +9,16 @@ class Typage {
a[3] = new C(4, 2);
a[4] = new D();
int somme = 0;
System.out.println(a[1].getClass());
for (int i = 0; i < a.length; i++) {
if (a[i] instanceof D) {
System.out.println(((D) a[i]).d);
} else {
if (a[i] instanceof B) {
somme = somme + ma(a[i]);
somme = somme + ma((B) a[i]); // otherwise a[i] isn't necessarily of type B required by ma()
if (a[i] instanceof C) {
C c = a[i];
C c = (C) a[i]; // otherwise a[i] isn't necessarily of type C required by mc()
c.mc();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment