用另一个替换String数组

时间:2018-01-07 18:09:43

标签: java android arrays

在开发Android项目时,我已经堆积在一个位置

这很简单

String[] subjects = {};
//It is a string array what I want transform by another
String[] another = {"Physics","Chemistry"};

如何将主题替换为另一个

1 个答案:

答案 0 :(得分:2)

像这样使用它会有所帮助

String[] subjects = {};
String[] another = {"Physics","Chemistry"};

subjects  = another.clone();

或第二个选项是这样的

subjects   = Arrays.copyOf(another , another .length);

这会将另一个数组复制到主题数组