Hi,
The problem is :

You are creating empty String array object
       string[] nameArrayForPerson = new string[];

you should define an array size and then create , for example

       int numPerson = 3;
       String[] family = new String[numPerson];

or
       String[] family = new String[3];


Please change your source code. After change it should work.

Kind regards,
Saidamin Usmanov


[email protected] wrote:

I'm at a loss for what to do with the homework. Here is what I have so far with the corresponding output.


import javax.swing.JOptionPane;

public class OwnJavaArray {

    public static void main(String[] args) {
        string[] nameArrayForPerson = new string[];
        int counter;
        int max = 0;
        int totalnumber = 3;

        // Prompt a user to enter numbers
        for(counter = 0; counter < totalnumber; counter++){

            nameArrayForPerson[counter] = Integer.parseInt
(JOptionPane.showInputDialog("Enter the family names until " + totalnumber + " sets of first and last names are entered"));

            // Compute the greatest name up to this point
            if((counter == 0)||(name[counter] > max))
                max = nameArrayForPerson[counter];

String[] nameArrayForPerson[counter] = person[counter]NameInstance.split(" ");

}

        // Display the name with the greatest length.
JOptionPane.showMessageDialog(null,"The name with the greatest length is " + max);
}






init:
deps-jar:
Compiling 1 source file to C:\Users\Owner\Documents\NetBeansProjects\MyInputFromKeyboardJOptionPaneProject\MyOwnJavaArrayProject\build\classes C:\Users\Owner\Documents\NetBeansProjects\MyInputFromKeyboardJOptionPaneProject\MyOwnJavaArrayProject\src\OwnJavaArray.java:6: array dimension missing
        string[] nameArrayForPerson = new string[];
C:\Users\Owner\Documents\NetBeansProjects\MyInputFromKeyboardJOptionPaneProject\MyOwnJavaArrayProject\src\OwnJavaArray.java:21: ']' expected String[] nameArrayForPerson[counter] = person[counter]NameInstance.split(" "); C:\Users\Owner\Documents\NetBeansProjects\MyInputFromKeyboardJOptionPaneProject\MyOwnJavaArrayProject\src\OwnJavaArray.java:21: illegal start of expression String[] nameArrayForPerson[counter] = person[counter]NameInstance.split(" "); C:\Users\Owner\Documents\NetBeansProjects\MyInputFromKeyboardJOptionPaneProject\MyOwnJavaArrayProject\src\OwnJavaArray.java:21: ';' expected String[] nameArrayForPerson[counter] = person[counter]NameInstance.split(" "); C:\Users\Owner\Documents\NetBeansProjects\MyInputFromKeyboardJOptionPaneProject\MyOwnJavaArrayProject\src\OwnJavaArray.java:27: reached end of file while parsing
}



Thanks in advance.
Rob B.
--
To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en To unsubscribe from this group, send email to javaprogrammingwithpassion+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to