Hello,
I am new in java programming. I'm doing an exercise on a Mooc and I have some trouble with my code.
The following code is supposed to return an array and I will print the values that are contained in it.
My problem is that the values of the array t are modified by the current affectation. How could I do to solve that?public static Element[] LZ77(int[] tab, int tailleFenetre) { int taille = LZ77Longueur(tab,tailleFenetre); Element[] t = new Element [taille]; Occurrence test = new Occurrence(0,0); Element temp = new Element(test,0); int c = 0; int element = 0; int i = 0; int next = 0; while (c < tab.length && tab[i+1]!=2) { test = plusLongueOccurrence(tab,c,tailleFenetre); int k = test.taille; int r = test.retour; next = tab[c+k]; c = c + k + 1; test.retour = r; test.taille = k; //temp.s = next; temp.e = test; temp.s = next; t[element]=temp; element ++; } t[t.length-1].s = 2; return t; }