any ideas, why this code doesn't compile?
package de.codegym.task.task12.task1205;
/*
Tiere erkennen
*/
public class Solution {
public static void main(String[] args) {
System.out.println(getObjectType(new Cow()));
System.out.println(getObjectType(new Dog()));
System.out.println(getObjectType(new Whale()));
System.out.println(getObjectType(new Pig()));
}
public static String getObjectType(Object o) {
// System.out.println(o.getClass().getSimpleName());
String s = "Unbekanntes Tier";
if (o instanceof Cow)
s = "Kuh";
if (o instanceof Whale)
s = "Wal";
if (o instanceof Dog)
s = "Hund";
return s;
}
public static class Cow {
}
public static class Dog {
}
public static class Whale {
}
public static class Pig {
}
}