fork(4) download
  1. public class BasicInteger
  2. {
  3. private int value;
  4. public BasicInteger (int v)
  5. {
  6. setValue (v);
  7. }
  8. protected void setValue (int v)
  9. {
  10. value = v;
  11. }
  12. public String toString()
  13. {
  14. return String.valueOf (value);
  15. }
  16. }
  17. public class EnhancedInteger extends BasicInteger
  18. {
  19. public EnhancedInteger (int v)
  20. {
  21. super (v);
  22. }
  23. public void change (BasicInteger bi)
  24. {
  25. super.setValue (bi.value);
  26. }
  27. }
  28. public class Test
  29. {
  30. public static void main (String[] args)
  31. {
  32. EnhancedInteger a = new EnhancedInteger (12);
  33. BasicInteger b = new BasicInteger (8);
  34. a.add (b);
  35. System.out.println ("Valeur : " + a);
  36. }
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class BasicInteger is public, should be declared in a file named BasicInteger.java
public class BasicInteger
       ^
Main.java:17: error: class EnhancedInteger is public, should be declared in a file named EnhancedInteger.java
public class EnhancedInteger extends BasicInteger
       ^
Main.java:28: error: class Test is public, should be declared in a file named Test.java
public class Test
       ^
Main.java:25: error: value has private access in BasicInteger
      super.setValue (bi.value);
                        ^
Main.java:34: error: cannot find symbol
      a.add (b);
       ^
  symbol:   method add(BasicInteger)
  location: variable a of type EnhancedInteger
5 errors
stdout
Standard output is empty