Java string[] partial copying

后端 未结 3 346
死守一世寂寞
死守一世寂寞 2020-12-20 19:25

How do I take a String[], and make a copy of that String[], but without the first String? Example: If i have this...

String[] color         


        
3条回答
  •  北海茫月
    2020-12-20 20:14

    String[] colors = {"Red", "Orange", "Yellow"};
    String[] copy = new String[colors.length - 1];
    System.arraycopy(colors, 1, copy, 0, colors.length - 1);
    

提交回复
热议问题