Joined: Wed May 04, 2011 11:54 am Posts: 1 Has thanked: 0 time Have thanks: 0 time
Write a java program asking the user to read two arrays as set of maximum 10 integer values and print the union of these two sets.
Plz give me fast answar as soon as posibel.......plz plz plz,,,,,,,,
msi_333
Question subject: Re: Question problem
Posted: Thu May 05, 2011 6:43 pm
Joined: Tue Mar 27, 2007 10:55 pm Posts: 2279 Location: Earth Has thanked: 39 time Have thanks: 61 time
this code snippet should help .
Code:
// scanner to read user input. Scanner myscan = new Scanner(System.in); List<Integer> arrayList = new ArrayList<Integer>(); // First array list . for(int i=0;i<10;i++){ int newvalue =myscan.nextInt();
if(arrayList.indexOf(newvalue)==-1){ // newvalue is not in array . arrayList.add(newvalue); } }
_________________ Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )