Total members 11893 |It is currently Tue Nov 05, 2024 5:24 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

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);
          }
        }
 


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  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 MySQL status value     -  
 print element in 2d matrix     -  
 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     -  



Topic Tags

Java Arrays






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com