Hello there:
I have not join to be a student yet...But I try to follow the
Labs...In Lab 1036, I follow...
I am wondering if there is the space for improvement....
Here is the prog...
package myfamilymemberarrayproject;
import javax.swing.JOptionPane;
/**
*
* @author Chris
*/
public class FamilyMemberArray {
/**
* @param args the command line arguments
*/
@SuppressWarnings("empty-statement")
public static void main(String[] args) {
String[] famNames = {"Christopher Chew", "Cindy Chew", "Dollars
Chew",
"ShiHuan Chew"};
String[] firstName ={"","","",""};
int[] lengthofFName = {0,0,0,0};
for (int i = 0; i < famNames.length; i++) {
String[] nameArray = famNames[i].split(" ");
JOptionPane.showMessageDialog(null,
"The Family members includes " + famNames[i]);
firstName[i] = nameArray[0];
lengthofFName[i] = firstName[i].length();
//System.out.println(lengthofFName[i]);
JOptionPane.showMessageDialog(null,
"The First Family mame is " + firstName[i]);
}
String tranS = firstName[0];
for (int j = 0; j < lengthofFName.length; j++) {
if(tranS.length() < lengthofFName[j]){
tranS = firstName[j];
}
}
JOptionPane.showMessageDialog(null,
"The Longest First Family name is " + tranS);
}
}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---