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