
Write a complete Java program that utilizes the JOptionPane method to get six names from the user and keep these names in an array of two rows and three columns named myNames[][]. Display all these twelve names in its proper order of two rows and three columns. Finally, display the number of times the name â??Aliâ?? appeared in the array, if any.

import javax.swing.*;
class StringArray
{
public static void main(String[] args)
{
int count=0;
String names[][]=new String[2][3];
for (int i=0 ; i < names.length ; i++){
for (int j=0 ; j < names[i].length ; j++){
names[i][j] = JOptionPane.showInputDialog("Enter Name");
}
}
System.out.println("Names: ");
for (int i=0 ; i < names.length ; i++){
System.out.println();
for(int j=0 ; j < names[i].length ; j++){
System.out.print(names[i][j]+" ");
if(names[i][j].equals("Ali")){
count++;
}
}
}
System.out.println();
System.out.println("Ali occurs "+count+" times");
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.