Java示例数组扩展


Java示例数组扩展

public class Main {

   public void extendArraySize() {

      String[] names = new String[] {"Sai", "Ram", "Krishna"};

      String[] extended = new String[5];

      extended[3] = "Prasad";

      extended[4] = "Mammahe";

      System.arraycopy(names, 0, extended, 0, names.length);



      for (String str : extended) System.out.println(str);

   }

   public static void main(String[] args) {

      new Main().extendArraySize();

   }

}