Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > Re: iterating t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 11 Topic 15994 of 16566
Post > Topic >>

Re: iterating through an array of String's

by voorth <voorth@[EMAIL PROTECTED] > Apr 21, 2008 at 03:51 AM

On Apr 21, 12:34 pm, thufir <hawat.thu...@[EMAIL PROTECTED]
> wrote:
> On Mon, 21 Apr 2008 07:58:23 +0000, thufir wrote:
> > I've looked around, but haven't found the information I was looking
for
> > yet.  Strictly looking at the syntax for assigning a row of
ADDRESS_DATA
> > to the address object, is there a more compact syntax?
> [...]
> >         //creates new instances of each Guest attribute //It might be
> >         better to treat name, contactInfo and address //as mutatable.
> >         Not a major point.
> >         public Guest newGuest(int row){
>
> Aha, now it works:
>         /*creates a new instance of guest from GUEST_DATA and
>         ADDRESS_DATA for a given row (guest id number?)
>         this method is more complex than it should be
>         but accomplishes the requirement of:
>         Write a separate class that creates three guests from a data
> array.
>         folding Name, Address and ContactInfo into one class
>         would simplify Lab2 enormously.  */
>         public Guest newGuest(int row){
>                 name = new Name(GUEST_DATA[row]);
>                 contactInfo = new ContactInfo(GUEST_DATA[row]);  //
> totally redundant
>                 address = new Address(ADDRESS_DATA[row]);
>                 Guest guest = new Guest(name,contactInfo,address);
>                 return guest;
>         }
>
> I swear that I'd tried to pass a row before and it didn't work, but,
> anyhow, now it does :)

Try
  java.util.Arrays.toString(data)

This will transform {"A", "B", "C"} to "[A, B, C]"
 




 11 Posts in Topic:
iterating through an array of String's
thufir <hawat.thufir@[  2008-04-20 08:50:00 
Re: iterating through an array of String's
Roedy Green <see_websi  2008-04-20 10:04:03 
Re: iterating through an array of String's
Thufir <hawat.thufir@[  2008-04-30 03:43:18 
Re: iterating through an array of String's
Roedy Green <see_websi  2008-04-20 10:05:35 
Re: iterating through an array of String's
voorth <voorth@[EMAIL   2008-04-21 03:51:03 
Re: iterating through an array of String's
Lew <lew@[EMAIL PROTEC  2008-04-21 07:12:00 
Re: iterating through an array of String's
thufir <hawat.thufir@[  2008-04-21 07:58:23 
Re: iterating through an array of String's
thufir <hawat.thufir@[  2008-04-21 10:34:52 
Re: iterating through an array of String's
Ian Kidder <ikidder@[E  2008-04-22 06:44:11 
Re: iterating through an array of String's
thufir <hawat.thufir@[  2008-04-23 04:06:25 
Re: iterating through an array of String's
Lew <lew@[EMAIL PROTEC  2008-04-23 00:19:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 16:10:05 CST 2008.