home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2716
Discussions: 188,384, Posts: 2,243,503, Members: 232,614
Old November 17th, 2002, 09:47 PM   Digg it!   #1 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
Java Q - To extend a class or not

I have a class Person that has a toString() method in it. My main class creates a person object and stores each person object as part of a vector. I know vectors have a built in toString() but I want the the default toString() to be the one I have created in the Person class. Would it be better to have the Person class extend the Vector class? (public class Person extends Vector) or create another class Vector and just have the toString() that I want in there.
__________________
YAH! I knew you'd be jealous

Tekk is offline   Reply With Quote
Old November 17th, 2002, 09:52 PM     #2 (permalink)
is 4 f00t secks
 
sixf00t4's Avatar
 
Join Date: Aug 2002
Location: Da Burgh
Posts: 4,509
Blog Entries: 3
i would just create another class vector.
__________________
Music (4/15/08) - Video (4/15/08) - blog - Legend of Six RPG

sixf00t4 is offline   Reply With Quote
Old November 18th, 2002, 01:33 AM     #3 (permalink)
Banned
 
qball's Avatar
 
Join Date: Oct 2001
Posts: 447
why are you using a "vector"?

http://java.sun.com/j2se/1.4.1/docs/...il/Vector.html

Quote:
My main class creates a person object
define 'main' class, or post person class object class code, then 'main' class code.

Quote:
My main class creates a person object
no, it doesn't.

qball is offline   Reply With Quote
Old November 18th, 2002, 02:34 AM     #4 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
Well Im using a vector because its part of the assignment.
Here is the code Im talkin about.
http://home.earthlink.net/~wolfman32x/PersonApp.txt


Last edited by Tekk : November 18th, 2002 at 02:37 AM.
Tekk is offline   Reply With Quote
Old November 18th, 2002, 08:15 PM     #5 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
Er... your code doesn't seem to call vector.toString() anywhere. Why would you want to call vector.toString() anyway?
strangerstill is offline   Reply With Quote
Old November 19th, 2002, 02:02 PM     #6 (permalink)
Ultimate Member
 
Tekk's Avatar
 
Join Date: Oct 2001
Location: Pasadena, CA
Posts: 2,152
Im a dummy Hehe...I see now that since the vector holds the Person object, it will automatically use the Person.toString() and not the vector.toString().
Tekk is offline   Reply With Quote
Old November 20th, 2002, 03:38 AM     #7 (permalink)
Senior Member
 
Join Date: Oct 2001
Posts: 881
Send a message via AIM to zskillz
qball.. i think you could be a bit nicer.

-Z
zskillz is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2896)
CPU wont boot (5)
3-days in and no threads about Gaza (160)
The United States Debt (20)
I think I just killed my computer w.. (24)
Upgrading RAM (5)
hp compaq nc6000 problems (138)
Folderchat Weekday thread (442)
Antec 300 bulk purchase? (11)
Recent Discussions
Folderchat Weekday thread (442)
CPU wont boot (5)
Creative T-3000 Subwoofer (3)
ACPI controller halt on boot (2)
Building a gaming computer advi.. (3)
Worth the upgrade?? (15)
ADVICE (0)
How to increase my ram? (5)
Help with an Ati Radeon HD 4850.. (27)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 10:12 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28