fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public interface People {
  11. String whoAmI = "People";
  12. void talk();
  13. }
  14.  
  15. public static class Human implements People {
  16. String whoAmI = "Human";
  17. public void talk() {
  18. System.out.println(whoAmI);
  19. }
  20. }
  21.  
  22. public static class Robot {
  23. String whoAmI = "robot";
  24. public void talk() {
  25. System.out.println(whoAmI);
  26. }
  27. }
  28.  
  29. public static void startTalk(Human human){
  30. human.talk();
  31. }
  32.  
  33. public static void main (String[] args) throws java.lang.Exception
  34. {
  35. Human human = new Human();
  36. Robot robot = new Robot();
  37.  
  38. startTalk(human);
  39. startTalk(robot); // 에러 발생(error: incompatible types)
  40.  
  41. }
  42. }
Compilation error #stdin compilation error #stdout 0.07s 49348KB
stdin
Standard input is empty
compilation info
Main.java:39: error: incompatible types: Robot cannot be converted to Human
		startTalk(robot); // ?? ??
		          ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error
stdout
Standard output is empty