I'm trying to override Variables that are already defined.
Here is my code:
package com.diesal11;
import java.lang.reflect.Array;
public class Test{
private class List {
public String[] words;
public List(String[] array) {
this.words = array;
}
}
public List[] all;
public Test() {
this.all = new List[2];
String[] array = new String[2];
array[0] = "One";
array[1] = "Two";
this.all[0] = new List(array);
array[0] = "Three";
array[1] = "Four";
this.all[1] = new List(array);
System.out.println(this.all[0].words[0]);
System.out.println(this.all[0].words[1]);
System.out.println(this.all[1].words[0]);
System.out.println(this.all[1].words[1]);
}
public static void main(String[] args) {
Test test = new Test();
}
}
The problem is the console prints out:
Three
Four
Three
Four
How can I fix this? the actual code I need this for is setup in this way so it can't change much.
Thanks in advance!