class T {
public int value;
public T(int i) {
this.value = i;
}
public String toString() {
return “Value: “ + this.value;
}
}
:
public static void func(T[] t) {
T tmp = t[0];
t[0] = t[1];
t[1] = tmp;
}
T[] vs = { new T(5), new T(3) };
func(vs);
System.out.println(vs[0]);
System.out.println(vs[1]);
public int value;
public T(int i) {
this.value = i;
}
public String toString() {
return “Value: “ + this.value;
}
}
:
public static void func(T[] t) {
T tmp = t[0];
t[0] = t[1];
t[1] = tmp;
}
T[] vs = { new T(5), new T(3) };
func(vs);
System.out.println(vs[0]);
System.out.println(vs[1]);