Hi !
I've got a problem with the homework of la 1036.
I understand now how the split method works. But I can't declare it
correctly, so I have two error messages.
Here's my code (I found part of it in another mail).
Can you help me to understand how it works ?
import javax.swing.JOptionPane;
public class OwnJavaArray {
public static void main(String[] args) {
int[] name = new int[10];
int counter;
int max = 0;
int totalname = 3;
int longest = 0;
// Prompt a user to enter numbers
for (counter = 0; counter < totalname; counter++){
name [counter] = Integer.parseInt
(JOptionPane.showInputDialog("Enter first name and last name of family
members until " + totalname + " names are entered"));
String[] names = name.split(" "); [Pb1]
if (names[0].length() > longest){
longest = names[0].length();
longestName = name;} [Pb2]
// Display the greatest number.
JOptionPane.showMessageDialog(null,"The name with the longest
first name value is " + name);
}
}
}
Problems :
[Pb1]. cannot find symbol : method split
[Pb2]. longestName is not defined; but I don't know how to to it. I
tried with int but it doen't work.
And I am not sure that longest is well declared.
Thank you
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---