+ 7
How to merge/concat two arrays?
2 Answers
+ 12
// The easy way is to convert the arrays into Lists, add one into another and finally convert back to an array.
import java.util.*;
class Program
{
public static void main(String[] args) {
String [] Burzum = {"Hvis lyset tar oss", "Det som engang var"};
String [] Emperor = {"In the nightside eclipse", "Anthems to the Welkin at dusk"};
List<String> list = new ArrayList<String>(Arrays.asList(Burzum));
list.addAll(Arrays.asList(Emperor));
Object[] MyFavouriteAlbums = list.toArray();
System.out.print(Arrays.toString(MyFavouriteAlbums));
}
}
// Or, there's another method if you check out this link... https://www.tutorialspoint.com/javaexamples/arrays_merge.htm
+ 6
Thank you very much!