fork download
  1.  
  2. class Str {}
  3.  
  4. interface Foo {}
  5. interface Bar {}
  6.  
  7. class Ideone
  8. {
  9. public static void main (String[] args) throws java.lang.Exception
  10. {
  11. String s = "";
  12.  
  13. Foo foo = (Foo) s; // Nope. String is definitely not a Foo
  14.  
  15. Bar bar = (Bar) foo; // Sure. A Foo might be a Bar
  16. }
  17. }
Compilation error #stdin compilation error #stdout 0.08s 51140KB
stdin
Standard input is empty
compilation info
Main.java:13: error: incompatible types: String cannot be converted to Foo
		Foo foo = (Foo) s; // Nope. String is definitely not a Foo
		                ^
1 error
stdout
Standard output is empty