:)
The problem I'm having: It's the very simplified version of what I'm trying to do, as I actually need to recount a large array of colors (taken from Color Object), and need to sort them, and remove and count duplicates in 2 arrays. (Or whatever data model I should use, I chose 2 arrays).
The problem I'v having is that I cant re-reference the array within a method the way it stays there afterwards.
public class Algos2 {
private int[] b1 = null;
public void relink(int[] a1, int[] a2) {
a2 = a1;
}
public Algos2() {
int[] a1 = { 0, 5, 5, 5, 3, 3, 0, 0, 1, 2, 1, 5};
relink(a1, b1);
System.out.println("a1 " + a1); // whatever, working
System.out.println("b1 " + b1); // still null
}
public static void main(String[] args) {
new Algos2();
}
}
b1should return the same pointer as a1 afterwards. And I need to do it within a method. :/
Edit: I also can't do it directly, returning an array by a method. So no: public int[] relink(int[] a1) {return a1;} as I also would neeed to call that from within another method, which also results in null