Multi Dimentional Arrays Java question
I don't know how to make this code work properly, I have a 2d array and have to check if the seat is available or is taken and mark as Free or Sold, first the loop keep running and second the check sometimes works and mark properly and sometimes even if a seat is free mask as sold. public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int[][] seats = { { 0, 0, 0, 1, 1, 1, 0, 0, 1, 1 }, { 1, 1, 0, 1, 0, 1, 1, 0, 0, 0 }, { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }, { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0 }, { 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, }; int roomRow = sc.nextInt(); int roomColumn = sc.nextInt(); for (int row = 0; row < seats.length; row++) { for (int column = 0; column < seats[row].length; column++) { if(row == roomRow && column == roomColumn) { System.out.println("Free"); } else { System.out.println("Sold"); } } } sc.close(); } } this is my code if anyone can help I'll be glad