doha786 0 Light Poster

hi,

i am looking for simple method to copy more than 2/3 arrays into one array..
so far i just learn to copy only two arrays at a time..

String[][] data=new String [10][];
String[] column={"Name", "Age", "Sex"};
String[][] first={{"Calvin", "male", "23"}, {"Kathy","female","21"}};

String[][] second={{"Ravi","male","26"},{"Jesan","male","25"}};
String[][] third={{"Jacky", "male", "32"}, {"Jami","female", "23"}};
String[][] fourth=.......;

data=Arrays.copyOf(first, first.length+second.length);
System.arraycopy(second, 0, data, first.length, second.length);
..
DefaultTableModel model=new DefaultTableModel(data,column);

is it possible to copy third or fourth array with single method like above or need to do part by part like this:

String newData=Arrays.copyOf(data, data.length+third.length);
System.arraycopy(third, 0, data, data.length, third.length);
DefaultTableModel model=new DefaultTableModel(newData,column);
...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.