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 O
  9. {
  10.  
  11. protected String X;
  12.  
  13. public O(String x) {
  14. this.X = x;
  15. }
  16. public void swap(O otherO) {
  17. System.out.println(this.X+" "+otherO.X+"\n");
  18.  
  19. String otherOX = otherO.X;
  20. otherO.X = this.X;
  21. this.X = otherOX;
  22.  
  23. System.out.println(this.X+' '+otherO.X);
  24. }
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28.  
  29. O L = new O("2");
  30. O R = new O("10");
  31.  
  32. L.swap(R);
  33.  
  34. }
  35. }
Success #stdin #stdout 0.12s 36812KB
stdin
Standard input is empty
stdout
2 10

10 2