As the code shows field os an empty array that I want to populate with the value l from another method I used arraycopy method and set the first array to point to the new added value but the output is gibberish .
Output:
[J@7dc5e7b4
I have tried with System.out.println(Arrays.toString(field));
but all it prints out is this [] empty brackets.
import java.util.*;
public class Aufgabe_04_02 {
static long[] field = new long[]{};
static void add(long l) {
long[] f1 = new long[field.length + 1];
System.arraycopy(field, 0, f1, 0, field.length);
f1[0]= l;
field= f1;
}// end add(longl)
public static void main(String[] args) {
long[] result = field;
System.out.println(result);
}// end main
}// end class