So is it possible to reference another array element from within a different array?
Like this
String[] array1 = new String[] {"World"};
String[] array2 = new String[] {"Hello", array1[0]};
array1[0] = "David";
for(String element : array2)
System.out.print(element);
When I try to print the array, it just prints HelloWorld and not HelloDavid
Is this possible? If not, is this possible using variables?
String[] array1 = new String[] {"World"}; String[] array2 = new String[] {"Hello", array1[0]}; array1[0] = "David"; array2[1] = array1[0]; for(String element : array2) System.out.print(element); }