Java string []部分复制 [英] Java string[] partial copying
本文介绍了Java string []部分复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取 String []
,并复制该 String []
,但不第一个字符串?
示例:如果我有这个......
How do I take a String[]
, and make a copy of that String[]
, but without the first String?
Example: If i have this...
String[] colors = {"Red", "Orange", "Yellow"};
我如何创建一个新的字符串,就像字符串集合颜色,但没有红色?
How would I make a new string that's like the string collection colors, but without red in it?
推荐答案
你可以使用 Arrays.copyOfRange
:
You could use Arrays.copyOfRange
:
String[] newArray = Arrays.copyOfRange(colors, 1, colors.length);
这篇关于Java string []部分复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文