Hi im trying to make a 10X10 board using arrays and have to fill up 2/3 of the board with the letter b, and 1/3 with the letter x. Right now i have created the board and my output shows up as zeros for some reason. can somebody please help? my code is as follows:

import java.util.Random;
public class Board
{
	int[][] board = new int[10][10];
	public Board(int[][] x)
	{
		x = board;
		generator = new Random();
		
	}
	public int getBoard()
	{
		return x;
	}
	private Random generator;
	private int x;

}


public class testBoard 
{

	public static void main(String[] args) 
	{
		Board b = new Board(null);
		final int Tries = 10;
		for (int i = 1; i<= Tries; i++)
		{
			int n = b.getBoard();
			System.out.println(n + " ");
		}
		System.out.println();
		
		

	}

}

and my output looks like this:
0
0
0
0
0
0
0
0
0
0

please help, im really confused. thanks :)

Assigning x = board does nothing. The variable x goes out of scope as soon as your method call returns. You should be saying board = x. Once you fix that, your program still will not work. You never created & initialized any values in your 2D array. Really, at this point, you need to go read about 2 dimensional arrays, variable scope, and how methods work in Java. Once you read up on all of that information you will be ready to start your project.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.