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. /* Name of the class has to be "Main" only if the class is public. */
  8. class static_out {
  9. static int x;
  10. static int y;
  11. void add(int a, int b){
  12. x = a + b;
  13. y = x + b;
  14. }
  15. }
  16. class static_use {
  17. public static void main(String args[])
  18. {
  19. static_out obj1 = new static_out();
  20. static_out obj2 = new static_out();
  21. int a = 2;
  22. obj1.add(a, a + 1);
  23. obj2.add(5, a);
  24. System.out.println(obj1.x + " " + obj2.y);
  25. }
  26. }
Success #stdin #stdout 0.15s 57544KB
stdin
Standard input is empty
stdout
7 9