-10

When developing an Android project I have got stacked in a position

It is so simple

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

How can I replace subjects with another

AA Shakil
  • 538
  • 4
  • 14

1 Answers1

2

use like this it will help

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

subjects  = another.clone();

or second option do like this

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

this will copy your another array into your subjects array

Sachin Rajput
  • 4,326
  • 2
  • 18
  • 29