Help with learning arrays
From: Jo Campbell (jocampbell_at_maine.rr.com)
Date: 11/28/04
- Next message: Mike B: "Re: nullpointerexception - PS"
- Previous message: Skip: "Re: nullpointerexception - PS"
- Next in thread: Mike B: "Re: Help with learning arrays"
- Reply: Mike B: "Re: Help with learning arrays"
- Reply: Andrew Thompson: "Re: Help with learning arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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);
}
}
}
- Next message: Mike B: "Re: nullpointerexception - PS"
- Previous message: Skip: "Re: nullpointerexception - PS"
- Next in thread: Mike B: "Re: Help with learning arrays"
- Reply: Mike B: "Re: Help with learning arrays"
- Reply: Andrew Thompson: "Re: Help with learning arrays"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|