daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest May 16th, 2018 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class IntHolder {
  2.     public IntHolder(int x) {
  3.         value = x;
  4.     }
  5.     public int value = 0;
  6.  
  7.     @Override
  8.     public String toString() {
  9.         return value+"";
  10.     }
  11. }
  12.  
  13. public class Main {
  14.  
  15.     static void swap(IntHolder a, IntHolder b) {
  16.         int t = a.value;
  17.         a.value = b.value;
  18.         b.value = t;
  19.     }
  20.     public static void main(String[] args) {
  21.         IntHolder a = new IntHolder(1);
  22.         IntHolder b = new IntHolder(0);
  23.         swap(a,b);
  24.         System.out.println(a+" "+b);
  25.  
  26.     }
  27. }
RAW Paste Data
Top