Mega Code Archive

 
Categories / Java Tutorial / Collections
 

Extend the size of an array

public class Main {   public static void main(String[] args) {     String[] names = new String[] { "A", "B", "C" };     String[] extended = new String[5];     extended[3] = "D";     extended[4] = "F";     System.arraycopy(names, 0, extended, 0, names.length);     for (String str : extended)       System.out.println(str);   } } /* A B C D F */