e.g. String [] address = {"rob st","king rd","mary st");
but i need to get the user to enter the data for that too, any help would be great
Expand|Select|Wrap|Line Numbers
- import java.io.*;
- public class test4
- {
- public static void main(String[] args) throws IOException
- {
- final int maxStudents = 10;
- String [] address = new String [maxStudents];
- String [] firstname = new String [maxStudents];
- String[] lastname = new String [maxStudents];
- String [] telno = new String [maxStudents];
- int activeEntries = 0;
- boolean found = false;
- int i = 0;
- String addressnosearch = Text.readString("Input name to search for, * to finish");
- while ( !addressnosearch.equals("*") )
- {
- found = false;
- i = 0;
- while ( !found && i < address.length)
- {
- if (address[i].equals(addressnosearch) ) //could use == true
- {
- found = true;
- }
- else
- {
- i++;
- }//end-if
- }//end-while
- if (found == true)
- {
- Text.showMessage ( addressnosearch + " was found in the array");
- }
- else
- {
- address[activeEntries] = addressnosearch;
- firstname[activeEntries] = Text.readString("Enter First Name " );
- lastname[activeEntries] = Text.readString("Enter Last Name " );
- telno[activeEntries] = Text.readString("Enter Telephone no " );
- activeEntries = activeEntries + 1;
- }//end-if
- }//end-while
- System.exit(0);
- }//main
- }//LinearSearch
i get this message after entering an address for
String addressnosearch = Text.readString("Input name to search for, * to finish");
Exception in thread "main" java.lang.NullPointerException
at test4.main(test4.java:31)
Process exited with exit code 1.