Hello I need help in my code
The problem is that it skips the index [0][0] and it I cannot enter a value and it displays blank.
So here's the output:
Enter row size: 3
Enter colum size: 4
Enter a string in location [0][0]: Enter a string in location [0][1]: asdw
Enter a string in location [0][2]: asdw
Enter a string in location [0][3]: asdw
Enter a string in location [1][0]: asdw
Enter a string in location [1][1]: asdw
Enter a string in location [1][2]: asdw
Enter a string in location [1][3]: asdw
Enter a string in location [2][0]: asdw
Enter a string in location [2][1]: asdw
Enter a string in location [2][2]: asdw
Enter a string in location [2][3]: asdw
The list of the following strings are:
asdw asdw asdw
asdw asdw asdw asdw
asdw asdw asdw asdw
Here's my code:
import java.util.Scanner; public class FSWtwo { public static void main (String[] args){ Scanner sc = new Scanner(System.in); System.out.print("Enter row size: "); int row = sc.nextInt(); System.out.print("Enter colum size: "); int column = sc.nextInt(); System.out.println(); String arr[][] = new String [row][column]; for(int x = 0; x < row; x++){ for(int y = 0; y < column; y++){ System.out.print("Enter a string in location [" + x + "][" + y + "]: "); arr[x][y] = sc.nextLine(); System.out.print(""); } } System.out.println("\nThe list of the following strings are: "); for(int x = 0; x < row; x++) { for(int y = 0; y < column; y++){ System.out.print(arr[x][y] + "\t "); } System.out.println(); } } }