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. class A {
  8. public int x = 99;
  9. }
  10.  
  11. class B extends A {
  12. public void f() {
  13. x = -1;
  14. }
  15.  
  16. public void g() {
  17. super.x = 123;
  18. }
  19. }
  20.  
  21. /* Name of the class has to be "Main" only if the class is public. */
  22. class Ideone
  23. {
  24. public static void main (String[] args) throws java.lang.Exception
  25. {
  26. B b = new B();
  27. System.out.println(b.x);
  28. b.f();
  29. System.out.println(b.x);
  30. b.g();
  31. System.out.println(b.x);
  32. }
  33. }
Success #stdin #stdout 0.1s 320256KB
stdin
Standard input is empty
stdout
99
-1
123