Wednesday, July 20, 2011

ArrayList

import java.util.ArrayList;



public class Main {

/**
* @param args
*/
public static ArrayList merge(String[] words, String[] more) {
ArrayList sentence = new ArrayList();
for (String w : words) sentence.add(w);
for (String w : more) sentence.add(w);
return sentence;
}
public static void main(String[] args) {
String[] northAmerica=new String[5];
northAmerica[0]="USA";
northAmerica[2]="CANADA";
northAmerica[1]="Mexico";
northAmerica[3]="Panama";
northAmerica[4]="Haiti" ;

String[] southAmerica=new String[5];
southAmerica[0]="Brazil";
southAmerica[1]="Argentina";
southAmerica[2]="Colombia";
southAmerica[3]="Uruguay";
southAmerica[4]="Venezuela";
ArrayList americanContr=new ArrayList();
americanContr=merge(northAmerica, southAmerica);
System.out.println(americanContr);
}

}

No comments:

Post a Comment