Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class IntHolder {
- public IntHolder(int x) {
- value = x;
- }
- public int value = 0;
- @Override
- public String toString() {
- return value+"";
- }
- }
- public class Main {
- static void swap(IntHolder a, IntHolder b) {
- int t = a.value;
- a.value = b.value;
- b.value = t;
- }
- public static void main(String[] args) {
- IntHolder a = new IntHolder(1);
- IntHolder b = new IntHolder(0);
- swap(a,b);
- System.out.println(a+" "+b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement