Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

Get union of two arrays set and print it

Thu May 05, 2011 8:05 am

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,,,,,,,,



Re: Question problem

Thu May 05, 2011 6:43 pm

this code snippet should help .
Code:

        
// scanner to read user input.
        
Scanner myscan = new Scanner(System.in);
        List<
IntegerarrayList = 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);
          }
        }
 


Post a reply
  Related Posts  to : Get union of two arrays set and print it
 can u check tis code to perform union & intersection of list     -  
 Help for Print using php     -  
 Print the ASCII Set     -  
 Print all files in a directory     -  
 print clock using JavaScript     -  
 Difference between PHP echo() and PHP print()?     -  
 Print all server variables     -  
 How to print a webcam picture in Jsp     -  
 Print all MySQL status value     -  
 print element in 2d matrix     -  

Topic Tags

Java Arrays