interface Printable {}
class BlackInk {}
public class Main {
public static void main(String args[]) {
Printable printable = null;
BlackInk blackInk = new BlackInk();
printable = (Printable)blackInk;
}
}
If the preceding code is compiled and run, the result is a ClassCastException at printable = (Printable)blackInk;
. But, if Printable is changed to a class, it doesn't compile because blackInk can't be cast to Printable. Why does it compile when Printable is an interface?