I'm assuming there are various ways to do that program. I'm interested in 
learning about the different ways in order to advance my programming skills and 
type LESS. :)

Tammy L. Estes
DAFS ~ OIT ~ ADAM 
Voice 207-624-8287
[EMAIL PROTECTED]

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On 
Behalf Of abstract26
Sent: Thursday, August 28, 2008 1:07 PM
To: Free Java Programming Online Training Course By Sang Shin
Subject: [java programming] Re: MyOwnJavaArrayProject Homework Questions


You can use a single array to hold three full names.

Note, that the split function returns an array itself, therefore
within a loop you can extract out the first name and second name in
another String array which holds the outcome from the split
function...

Something like this

String []fname;

fname=names[i].split(" ");
fname[0] will hold the first name
fname[1] will hold the last name

Just use fname[0].length() for comparison for all three first names.

I think its better solution then creating three sepearte arrays.


On Aug 28, 1:07 pm, "Estes, Tammy" <[EMAIL PROTECTED]> wrote:
> I completed the homework already for MyOwnJavaArrayProject, got it to
> work and passed it in.
>
> Now a day or two after I start thinking about "easier ways" I could have
> written my program. It is funny how this course really makes you think
> doesn't it??
>
> Anyway... this is my question:
>
> Is this:
>
> //System.out.println("Splitting the three names now...");
>
> String[] FirstPersonFirstName = strArray[0].split(splitter);
>
>  String[] SecondPersonFirstName = strArray[1].split(splitter);
>
>  String[] ThirdPersonFirstName = strArray[2].split(splitter);
>
> The absolute BEST way to split the three or can I use something like
> this?
>
> String [] strFname = {" ", " ", " ", }; // an array to hold the 3 first
> names
>
> for (int i = 0; i < strFname.length; i++){
>
>              System.out.println("Beginning loop now to split names
> now...");
>
>              String[] strFname = strArray[0].split{splitter);  
>
>         }
>
> I tried the last line and get an error ( ; needed) but I think I'm close
> to getting something I can easily work with.
>
> Just trying to find easier ways to write it all out.
>
> In any case, I did the additional work as PRACTICE to make sure I
> understand arrays and can work with them easily without putting too much
> thought into it. I also added ternary operators in the second version in
> place of the if-else statement.
>
> So any thoughts on this above would be helpful!
>
> Thanks,
>
> Tammy L. Estes
>
> DAFS ~ OIT ~ ADAM
>
> Voice 207-624-8287
>
> [EMAIL PROTECTED]



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to