473,379 Members | 1,335 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,379 software developers and data experts.

How to convert Object to Vector

hi,

I have converted vector to object. How can I convert Object into Vector.

My code look like this,

Expand|Select|Wrap|Line Numbers
  1.  
  2. Vector column=new Vector();
  3. column.add("one");
  4. column.add("two");
  5. Object ob=column;
  6. //here i am calling a method
  7. mymethod(ob)
  8. {
  9. // how can i convert ob Object to Vector 
  10. }
  11.  
Thanks in advance.
Jul 24 '08 #1
5 17320
r035198x
13,262 8TB
Typecasting.
Expand|Select|Wrap|Line Numbers
  1. Vector v = (Vector)ob;
Your code doesn't look all that clean though.
Why are you changing the Vector to the object in the first place? Also note that Vectors are old. Rather use ArrayList. It's probably what you want to use there.
Jul 24 '08 #2
Brosert
57
Depends what you mean convert....
Given that the object (ob) was originally a Vector, you can cast it to a Vector.....

eg to print the first object
Expand|Select|Wrap|Line Numbers
  1. prinln(((Vector)ob).get(0).toString());
  2.  
Jul 24 '08 #3
hi,

I have to receive ob as String(with the same vector value again i have to convert Vector here). Like

void mymethod(String s)
{
Vector v = (Vector)s ; // like this
}

How can i do this.
Jul 24 '08 #4
hi,

Is there any way to convert Vector to String?.

Thanks in advance.
Jul 24 '08 #5
r035198x
13,262 8TB
hi,

Is there any way to convert Vector to String?.

Thanks in advance.
In your code above, you are trying convert a String to a Vector not a Vector to a String.
The best thing here is for you to explain the problem you are trying to solve. All the type juggling you are tring to do can be avoided by designing your solution properly. Tell us your problem definition.
Jul 24 '08 #6

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

Similar topics

2
by: Max | last post by:
I just wonder if there is a way of converting an object to a string. I am using a function to send an object parameter e.g "fctng(train0);" later on I would like to use train0 but as a string to...
10
by: bluekite2000 | last post by:
and why doesnt the standard vector have such conversion available?
2
by: Nikolay Petrov | last post by:
How can I convert variable of type Object to Byte array? TIA
5
by: tienlx | last post by:
Hi all, I'm have a problem that i don't know how to convert object to char in C# . Does anybody know ? Thanks.
0
by: bacsumu | last post by:
i'm programming in c# i use embeded webbrowser ----------------------------------------------------- int Exec( ref Guid pguidCmdGroup, int nCmdID, int nCmdexecopt,
1
by: bmc | last post by:
How can we convert c++ vector to java vector in native method?
0
by: suneethadotnet | last post by:
hi , object objee= obj1.GetSecurityInfo("hi"); here GetSecurityInfo("hi") returns struct.i am assigning it to object.now the object objee have all the properties of GetSecurityInfo("hi")...
2
by: Charming12 | last post by:
Hi All, I am stuck with a unique problem, I have a class whose object i need to convert to a byte to send it further. I am using microsoft's Binaryformatter to convert object to byte as per...
13
by: dpsairam | last post by:
Hi, How to convert a Vector to a Byte array....i have vector which contains a Byte array.....i need to convert the vector into Byte array... ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.