I have created this code (with the help of Reimeus). How would I achieve to instead of replace every value in the array with true to replace only one pre determined (by z for example) and this always being a value on the top column of the 2d array. Furthermore I would like to how I should start to get instead of the output being true and false it being x for true and y for false but still keeping the array an boolean
import java.util.*; class Main { public static void main(String[] args) { int x; int y; Scanner scanner; scanner = new Scanner(System.in); x = scanner.nextInt(); y = scanner.nextInt(); boolean[][] cells = new boolean[x][y]; for (int i = 0; i < cells.length; i++) { Arrays.fill(cells[i], true); System.out.println(Arrays.toString(cells[i])); } } }
"it doesnt seem to work"is not best way to describe problem. What output you get and what you expect?