Help with learning arrays

From: Jo Campbell (jocampbell_at_maine.rr.com)
Date: 11/28/04


Date: Sun, 28 Nov 2004 17:12:01 GMT

I would like to create an array where I can generate a random number and
have it "move" to that particular spot on the array
and then give me a JOptionPane that tells me where it went. I just can't
seem to make the leap to figure out what to do next. Can someone clue me
in? Thanks!

import java.util.Random;
public class test{
 public static void main (String args[]){

 int array1[][]=new int [6][6];
      for (int i=0; i<6; i++)
           for (int j=0; j<6; j++)
                array1[i][j]=0;

 int r = 0;
 int moves = 0;

 for (moves = 0; moves<100; moves++)
 {

 Random generator = new Random();
 int num1;

 num1 = generator.nextInt(7);

 }

}
}



Relevant Pages

  • Re: StringTokenizer to return empty tokens
    ... > to an array: ... Since StringTokenizxer is known not to be able to handle this problem, ... IMHO is really dreadful to use, ...
    (comp.lang.java.help)
  • Re: simple array question...
    ... >> public class test{ ... > You have an array of size zero, and index 0 of such an array is not ... a is initialized to zero. ... step 5 doesn't cause array to change sizes. ...
    (comp.lang.java.help)
  • Re: simple array question...
    ... You have an array of size zero, and index 0 of such an array is not ... step 5 doesn't cause array to change sizes. ...
    (comp.lang.java.help)
  • Re: Sorting an array. Fastest way.
    ... Sorting the Array. ... Are you simply wanting to sort an int? ...
    (comp.lang.java.programmer)
  • Re: array of objects in a User Control
    ... I dont' think the designer can serialize it to the array very well, ... > that brings up a window that allows me to add new items and set their ...
    (microsoft.public.dotnet.general)