public class Exercise {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String A[] = { "Joseph","Ariana","Xena","Rene","Peter","Diana","Rihanna"};
String B[] = {"Madona","Diddy","Joe","Alice"};
for(int j = 0; j < A.length; j++) {
for(int s = j +1; s < B.length; s++)
for(int i = 0 ; i < B.length; i++) {
if(A[j].compareToIgnoreCase(B[i]) < 0) {
}
}
List<String> list = new ArrayList(Arrays.asList(A));
list.addAll(Arrays.asList(B));
Object[] C = list.toArray();
System.out.println(Arrays.toString(C));
}
}
}
And the out put was like this:
run:
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
[Joseph, Ariana, Xena, Rene, Peter, Diana, Rihanna, Madona, Diddy, Joe, Alice]
BUILD SUCCESSFUL (total time: 6 seconds)