Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jul 10th, 2005, 3:26 AM   #1
secrecy230
Newbie
 
Join Date: May 2005
Posts: 11
Rep Power: 0 secrecy230 is on a distinguished road
fill array with unique numbers

fill Array with unique number
i have to construct an array of integers and i have to which will generate six integer values in the range 1 to 45 inclusive. The algorithm must loop until all of the six numbers generated are unique


for now i ahve only be able to do that part>>

import java.util.Random;
class s1_1999
{
private static int[] fillArray(int [] array)
{
Random random = new Random();
for(int row = 0 ; row < array.length ;row++)
{

array[row]=random.nextInt(10);

}


private static boolean compare(int [] testarray)
{
boolean test=false;
int testValue=0;
for(int row = 0; row<testarray.length;row++)
{
for (int i=1 ;i<testarray.length ; i++)
{
if(testarray[row]==testarray[i])
{
test=true;

}

}

return test;

}






public static void main(String []args)
{
int [] inarray=new int[6];

fillArray(inarray);

}



can you help me to complete this java program plz??????????
thanx in
advance
from
andy

Forum: Java Post New Thread
Logged in as secrecy230
Title:

Message:
secrecy230 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:16 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC