fork download
  1. class A
  2. {
  3. int s;
  4. public void setName(int a )
  5. {s=a;}
  6. public int getName()
  7. {
  8. return s;
  9. }
  10.  
  11. }
  12.  
  13. class Testf{
  14. A b=new A();
  15. public static void exe()
  16. {
  17. b.setName(10);
  18. //(new A()).setName(14);
  19. }
  20.  
  21. public static void main(String [] args) {
  22. exe();
  23. System.out.println("values:" +(new A()).getName());
  24. System.out.println("values:" +(new A()).getName());
  25. }
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:17: non-static variable b cannot be referenced from a static context
b.setName(10);
^
1 error
stdout
Standard output is empty