package name;
import javax.swing.*;
import java.awt.*;
public class Main {
public static String name[][]=new String[100][2];
public static void main(String[] args) {
boolean repeatnames=true;
boolean search=true;
int s;
int b;
int i=0;
int n;
int w=0;
String mainm;
String searchnames;
String searchnick;
String addname;
String nam;
String nick;
String names;
String fname;
String m;
do{
repeatnames=false;
mainm=JOptionPane.showInputDialog("What do you want to do?"+'\n'+"1. Enter Names"+'\n'+"2. Search For Names");
s=Integer.parseInt(mainm);
switch(s){
case 1:
names = JOptionPane.showInputDialog("What is the name you are entering?");
System.out.println(names);
nick = JOptionPane.showInputDialog("What is the nick name of this person?");
System.out.println(nick);
name[i][w]=names+nick;
i++;
System.out.println(name[i][w]);
repeatnames=true;
break;//end of case 1
case 2:
searchnames = JOptionPane.showInputDialog("What Are you loking for?"+'\n'+"1. name");
b=Integer.parseInt(searchnames);
switch(b){
case 1:
fname = JOptionPane.showInputDialog("What is the name you are looking for?");
System.out.println(fname);
i=0;
search=true;
do{
if(name[i][1].equals(fname))
{
JOptionPane.showMessageDialog(null,"the nick name for "+fname+" is "+name[i][w]);
System.out.println(name[i][w]);
search=false;
repeatnames=true;
}
else
i++;
}while(search);
break;
}
break;
}
}while(repeatnames);
}
}
Right here i am getting a NullPointerException but dont know why
Please help
if(name[i][1].equals(fname))
thanks
Storm(yes thats my real name)

New Topic/Question
Reply




MultiQuote





|