Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

array of numbers-randomised

800640Dec 11 2008 — edited Dec 12 2008
i am trying to create a array full of random numbers which i have done with:
public void randArray(int[][]rand){
      for (row=0; row<rand.length; row++)
  {
   for (col=0; col<rand[row].length; col++)
   {
     t = (int)(Math.random()*6);
     rand[row][col] = t;
   }
      }
   }
but i need it so that it has 2 of each random number not just 1
eg if i printed out the array and took the each number they wud be in multiples of 2

rand = 2 4 5 0
1 2 0 3
3 2 5 1
0 0 4 2

reading that back myself i dont think it makes any sense at all but i cant think of any other way to describe it
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 9 2009
Added on Dec 11 2008
18 comments
205 views