Monday, 30 April 2018



//How to merge two array?

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayMerge {
public static void main(String[] args) {
String []s1= {"govind","ballabh","khan"};
String []s2= {"java","technology"};
List<String> l=new ArrayList<String>(Arrays.asList(s1));
    l.addAll(Arrays.asList(s2));
    Object[] o = l.toArray();
    System.out.println(Arrays.toString(o));

}

}



o/p:------------------

[govind, ballabh, khan, java, technology]

No comments:

Post a Comment