向原有数组中添加元素

package com.zbp;

import java.util.Arrays;

public class TestArray {
         static String[] s1={ "a", "b", "c"};
         public static void main(String[] args) {
                 s1=Arrays.copyOf(s1, s1.length+1);
                 s1[s1.length-1]= "d";
                 for(String s:s1){
                         System.out.println(s);
                 }
         }
}

你可能感兴趣的:(java,职场,数组,休闲,添加元素)