
Pl correct this program. This program will take character from user and show all the name which start that character.
import javax.swing.*; class Name1{ public static void main (String arg[]){ char ch; String =JOptionPane.showInputDialog(null,"Enter any character"); switch(ch){ case 1: JOptionPane.showMessageDialog(null,"Ali\n Azam\n Afzal\n"); break; case 2: JOptionPane.showMessageDialog(null,"Babar\n Bebo\n Bell\n"); break; default: JOptionPane.showMessageDialog(null,"Invalid"); } } }

Display name which starts with particular character
import javax.swing.*;
class Name1{
public static void main (String arg[]){
String st=JOptionPane.showInputDialog(null,"Enter any character");
char ch=st.charAt(0);
switch(ch){
case 'a': JOptionPane.showMessageDialog(null,"Ali\n Azam\n Afzal\n");
break;
case 'b': JOptionPane.showMessageDialog(null,"Babar\n Bebo\n Bell\n");
break;
default:
JOptionPane.showMessageDialog(null,"Invalid");
}
}
}
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.