• Post Reply Bookmark Topic Watch Topic
  • New Topic

Converting a Vector to a String

 
Luke Chadwick
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im in some dire need of some basic help. Im having a problem trying to convert a vector to a string. I have a JComboBox which shows the data which is obtained from a database and placed into a combo box, and this works fine.
I want it so that when a select a value in a combobox, that value is then passed/placed into a jtextfield, and so need to convert a vector to a string (array possibly), im completely stuck on this.
Please help a poor student out.
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch Luke!
This is from the API for Vector:
public String toString()
Returns a string representation of this Vector, containing the String representation of each element.

This means that the method toString in Vector class has overriden the default implementation that inherits from Object.toString. Because toString is declared in Object all their subclasses inherit it. It was sensible to look up the API to see if Vector had overriden it.
I always have the API link bookmarked in a bar of Mozilla. It is absolutely compulsary.
[ March 06, 2004: Message edited by: Jose Botella ]
 
Vishal Methi
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
So u got the soultion how to convert the vector into string but i thought u dont need to convert vector into String for your requirement....
You can select the value directly from combobox just by the method
jCombobox.getSelectedObject return object convert it into string by toString method and if u want an index u get it by jComboBox.getSelectedIndex return and integer value..........
Vishal
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!