import javax.swing.JOptionPane;


public class OwnJavaArray {


public static void main(String[] args) {


String[] name = new  String[3];
for (int x = 0; x < name.length; x++) {
int number  = x + 1;
name[x] = JOptionPane.showInputDialog(null, "Please enter  first and last name " + number);
}
String[] name0 =  name[0].split(" ");
String[] name1 = name[1].split(" ");
String[] name2 = name[2].split(" ");
String longName =  (name0[0].length() > name1[0].length()) ? name0[0] : name1[0];
longName = (longName.length() > name2[0].length()) ? longName :  name2[0];
JOptionPane.showMessageDialog(null, "The longest name is "  + longName);


     }
}

Tags:

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

blog comments powered by Disqus