It is not difficult.

e.g.

String longestString = "";
for (int i; i<myString.length; i++){
  if(myString[i].lenght > longestString.length){
     longestString = myString[i];  // If there is longer string than 
 current longest string assign it to longest string
  }
}
--
Martin


Dne čtvrtek, 27. února 2014 22:19:08 UTC+1 Rahul Sharma napsal(a):
>
> This is what's asked of us:
>
> Ask the English version of the first names of three of your family members 
> using showInputDialog() method of the JOptionPane class. Display the name 
> of the family member who has the longest first name as following. (If there 
> is a tie, just display one of the two.) Daniel has the longest first name.
>
> This is what I have so far and am stuck:
>
> 'import javax.swing.JOptionPane;
>
> public class Foothill {
>
> public static void main(String[] args) {
>
>     String[] names = new String[2];
>
>     for(int x=0; x < 4; x++){
>
>         names[x] = (JOptionPane.showInputDialog("Enter your mothafuckin 
> name"));
>
>         for(int j=0; )
>         }
>     if();{
>
>              JOptionPane.showMessageDialog(null,"The number with the greatest 
> value is " + Max);
>         }
>     }}'
>
> I'm having a hard time understanding how to test the length of each string 
> in the array and then comparing the length of the strings within the array. 
> I understand there are built-in methods to do this, but can someone please 
> explain how to do this through iteration? Thanks!
>

-- 
You received this message because you are subscribed to the Google Groups 
"JPassion.com: Java Programming" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/jpassion_java.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to