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.  
  8. class A {
  9. private String foo;
  10.  
  11. A () {
  12. }
  13. }
  14.  
  15. class B extends A {
  16. B () {
  17. }
  18. }
  19.  
  20.  
  21.  
  22. /* Name of the class has to be "Main" only if the class is public. */
  23. class Ideone
  24. {
  25.  
  26.  
  27. public static void main (String[] args) throws java.lang.Exception
  28. {
  29. A a = new A();
  30. B b = new B();
  31.  
  32. System.out.println(a.foo);
  33. System.out.println(b.foo);
  34. }
  35. }
  36.  
  37.  
  38.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:32: error: foo has private access in A
		System.out.println(a.foo);
		                    ^
Main.java:33: error: foo has private access in A
		System.out.println(b.foo);
		                    ^
2 errors
stdout
Standard output is empty