So what I'm trying to do is to add an array of strings to my Arraylist BDDvars. The issue I seem to be facing is that after adding 'temp' (which is an array of strings) to the BDDvars list, when I instantly print -- I get values. However, after reinitializing temp, somehow the values that were present in my arraylist are also reset. Would appreciate some help on why this is happening. Thanks!
Code is here:
List<String[]> BDDvars =new ArrayList<String[]>();
BDDvars.add(temp);
System.out.println(BDDvars.get(0)[0]); // this gives value of temp
for(int n =0;n<11;n++)
temp[n] = "";
System.out.println(BDDvars.get(0)[0]); // this gives empty string - why?