Original Post
Here''s some stopid code for a stoopid thing I was messing around with.
import java.util.*;
class ArrayClass {
String [] [] contents =new String[9][9];
public void fill(){
for (int i=0;i<9;i++){
for (int j=0;j<9;j++) {contents[j]= "A";}}}
public void print(){
for (int i=0;i<9;i++){
for (int j=0;j<9;j++) {System.out.print(contents[j]);if (j==8) System.out.println (" "); }}}
public void mutate() {
Random rand = new Random();
int range=9;
int x;
int y;
for (int mute=0;mute<6;mute++){
x= (rand.nextInt(range));y=(rand.nextInt(range));
contents[x] [y] = "*";}
}
public String [][] getarray() {
return contents ;
}
public static void main(String[] arguments) {
ArrayClass poop = new ArrayClass();
poop.fill();
String [] [] temp = new String [9][9];
!!!!temp = poop.getarray();
poop.contents[5][5]="7";
poop.mutate ();!!!!
for (int i=0;i<9;i++){
for (int j=0;j<9;j++) {System.out.print(temp[i][j]);if (j==8) System.out.println (" "); }}
Section marked with !!!! is the bit that seems fishy. What the whole program should do is create and arrayclass with a multidim array that gets filled with ''A'' and the mutate function changes 6 of the A''s into "*".In the void main a new array (temp) is created and and the final bit should print out the array (temp) in a little 9,9 square.
Only trouble is that it seems to print it with the mutated "*"''s which it shouldn''t. Mutate is called after getarray...