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: ArrayList.t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 11 Topic 15990 of 16192
Post > Topic >>

Re: ArrayList.toString versus iterating through the ArrayList

by Hendrik Maryns <gtw37bn02@[EMAIL PROTECTED] > Apr 19, 2008 at 12:18 PM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

thufir schreef:

| However, in the below code, calling guests.toString() gives no output.

Why do you think so?  It gives a String.  But you don’t do anything with
it.  You have to direct it to stdout to see it on the command line
|     public static void main (String[] args)
|     {
|                         loadGuests();
|                         printGuests();   //prints out the guests
| 			//guests.toString;  //gives no output at all.why?
System.out.println(guests);
No need even to call toString, println does that for you.

| public class Guests extends ArrayList <Guest>

Don’t do this.  Prefer composition over inheritance (google for this).

HTH, H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFICccOe+7xMGD3itQRApuTAJ4pIZGg2fTXL1nygt/a/dP8PWhAcACfXtCW
WpeZiTnuNHOPWnPH0H9thbY=
=p1CI
-----END PGP SIGNATURE-----
 




 11 Posts in Topic:
ArrayList.toString versus iterating through the ArrayList
thufir <hawat.thufir@[  2008-04-19 09:41:29 
Re: ArrayList.toString versus iterating through the ArrayList
Hendrik Maryns <gtw37b  2008-04-19 12:18:54 
Re: ArrayList.toString versus iterating through the ArrayList
Lew <lew@[EMAIL PROTEC  2008-04-19 09:18:21 
Re: ArrayList.toString versus iterating through the ArrayList
thufir <hawat.thufir@[  2008-04-19 22:44:33 
Re: ArrayList.toString versus iterating through the ArrayList
Lew <lew@[EMAIL PROTEC  2008-04-19 22:52:07 
Re: ArrayList.toString versus iterating through the ArrayList
Roedy Green <see_websi  2008-04-20 10:37:38 
Re: ArrayList.toString versus iterating through the ArrayList
Roedy Green <see_websi  2008-04-20 10:39:47 
Re: ArrayList.toString versus iterating through the ArrayList
xinxin <jnzhouxinxin@[  2008-04-20 04:41:09 
Re: ArrayList.toString versus iterating through the ArrayList
Lew <lew@[EMAIL PROTEC  2008-04-20 09:36:58 
Re: ArrayList.toString versus iterating through the ArrayList
thufir <hawat.thufir@[  2008-04-20 20:36:09 
Re: ArrayList.toString versus iterating through the ArrayList
thufir <hawat.thufir@[  2008-04-20 20:38:16 

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 Jul 5 15:41:51 CDT 2008.