Here's my code, my problem is that after I enter the values for rowNum and colNum, it displays the "Please enter a value" prompt twice and fills the first part w/ a space it seems like. Help would be appreciated!
import java.util.*;
public class Lab11 {
public static void main(String[] args){
// A scanner object for requesting input from the user
Scanner scan = new Scanner(System.in);
// An integer for the number of rows.
int rowNum;
// An integer for the number of columns.
int colNum;
//a string search for the string to search for
String search;
// Print this message "Enter the number of rows in the array" //
System.out.print("Enter the number of rows in the array" );
rowNum = scan.nextInt();
// Print this message "Enter the number of columns in the array //
System.out.print("Enter the number of columns in the array");
colNum = scan.nextInt();
// Use the scanner to store the values entered by the user
// in the integers declared above.
// Declare a 2D String array using the number of rows and columns previously entered by the user
String[][] stringArray = new String[rowNum][colNum];
for (int i = 0; i < stringArray.length; i++){
for (int j = 0; j < stringArray[i].length; j++){
System.out.println("Please enter a value");
stringArray[i][j] = scan.nextLine();
}
}
for (int ii = 0; ii < stringArray.length; ii++){
for (int jj = 0; jj < stringArray[ii].length; jj++){
System.out.print(stringArray[ii][jj]+" ");
}
System.out.println();
}
System.out.println("Please enter the string you are searching for");
search = scan.nextLine();
for (int iii = 0; iii < stringArray.length; iii++){
for (int jjj = 0; jjj < stringArray[iii].length; jjj++){
if(stringArray[iii][jjj].equals(search)){
System.out.println("Element found at position ("+iii+","+jjj+")");
}
}
}
}
}