473,401 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

vectorname.get(vectorelement).toString() error

daiyen
9
Hello everyone!

I couldn't find any other topics like this, so I hope I won't start a redundant discusson.

My problem is the following:

I want to get an element of my vector but it turns out that toString() method doesn't work properly for me.

My code looks like this:
Expand|Select|Wrap|Line Numbers
  1. for(int i=0; i<f_versenyzok.size() ; i++)
  2. System.out.println(f_versenyzok.get(i).toString());
  3.  
and I get the following output:

Expand|Select|Wrap|Line Numbers
  1. Magasugro@c17164
  2. Magasugro@1fb8ee3
  3.  
I can't figure out why, because it is supposed work properly.
I also imported java.util.*, maybe..but it just didn't seem to work.

Thanks for your help!
Oct 9 '08 #1
3 1601
JosAH
11,448 Expert 8TB
Hello everyone!

I couldn't find any other topics like this, so I hope I won't start a redundant discusson.

My problem is the following:

I want to get an element of my vector but it turns out that toString() method doesn't work properly for me.

My code looks like this:
Expand|Select|Wrap|Line Numbers
  1. for(int i=0; i<f_versenyzok.size() ; i++)
  2. System.out.println(f_versenyzok.get(i).toString());
  3.  
and I get the following output:

Expand|Select|Wrap|Line Numbers
  1. Magasugro@c17164
  2. Magasugro@1fb8ee3
  3.  
I can't figure out why, because it is supposed work properly.
I also imported java.util.*, maybe..but it just didn't seem to work.

Thanks for your help!
Given that output I can see that your Vector stores Magasugro objects (or derived
classes thereof). That class doesn't override the toString() method so the default
implementation (in the Object class) is used.

kind regards,

Jos
Oct 9 '08 #2
daiyen
9
Given that output I can see that your Vector stores Magasugro objects (or derived
classes thereof). That class doesn't override the toString() method so the default
implementation (in the Object class) is used.

kind regards,

Jos
I see mate. So in order to see any correct results I should override toString() method. Imho I'll rather do it a different way then.

Thanks for your help!
Oct 9 '08 #3
JosAH
11,448 Expert 8TB
I see mate. So in order to see any correct results I should override toString() method. Imho I'll rather do it a different way then.

Thanks for your help!
You're welcome but don't do it another way: if an object wants to display itself
properly it should take care of that itself. The toString() method is ideal for those
purposes. Any other way would be a hack.

kind regards,

Jos
Oct 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MFS 43 | last post by:
Have two tables with identical fields (access 2002). Trying to combine DATA. I created two recordsets based on these two tables. then I used code that looks like this.: with rstmain
5
by: Richard | last post by:
I have been struggling with this for days. I feel I must be missing something simple, and I will be eternally grateful for any help. I'm using VS.NET 2003 on XP Pro Sp2. I searched and found...
2
by: ad | last post by:
Hi, I use the setting below in Web.config <customErrors mode="On" defaultRedirect="~/ErrorPage/GenericErrorPage.aspx" /> How could we get error statusCode when GenericErrorPage is load?
4
by: mmnenator | last post by:
When I send mail use smtpmail get error: Mailbox unavailable.(asp.net 2.0)
0
by: Chandra Mohan | last post by:
how do I get error codes like 404 - access error, 502 - bad gateway.. 505 etc programatically from the exception? WebException has a status field which gives generic error tag like protocolerror....
2
by: Gunnar G | last post by:
Hi. How do you get error messages if you have only ftp put/get (no shell access) and display error is turned off? Is there any clever way of getting them?
2
by: satnamsarai | last post by:
Using System.Net.Mail: Sometimes I get error 'failure sending mail. Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host.' Not sure how...
11
by: RP | last post by:
If an exception occurs, how to get the error number. I mean, is there anything like ex.number?
1
by: ncsthbell | last post by:
I have an Access 2000 database (running on Windows XP) that is used as a model and each user grabs a copy of this and puts onto their own drive. I have had 2 folks have issues with it lately. When...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.