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

Vectors as Strings

how to pass string as vector object
Sep 4 '07 #1
10 1514
r035198x
13,262 8TB
how to pass string as vector object
What do you mean by that?
Sep 4 '07 #2
dmjpro
2,476 2GB
how to pass string as vector object
Welcome to TSDN.

What you want, if I am not wrong..... You want a String as a Vector Element.
Or, (String)new Vector().

Kind regards,
Dmjpro.
Sep 4 '07 #3
JosAH
11,448 Expert 8TB
(String)new Vector()[/b].

Kind regards,
Dmjpro.
That cast will fail miserably; even the compiler can detect that. Maybe you mean:

Expand|Select|Wrap|Line Numbers
  1. (new Vector()).toString();
  2.  
... which doesn't do anything useful either.

kind regards,

Jos
Sep 4 '07 #4
Nepomuk
3,112 Expert 2GB
That cast will fail miserably; even the compiler can detect that. Maybe you mean:

Expand|Select|Wrap|Line Numbers
  1. (new Vector()).toString();
  2.  
... which doesn't do anything useful either.

kind regards,

Jos
Or maybe you mean:
Expand|Select|Wrap|Line Numbers
  1. String someString = (String) Vector.elementAt(i);
However, if you're using Java 1.5 or later, just use the Vector like this:
Expand|Select|Wrap|Line Numbers
  1. Vector<String> someVector = new Vector<String>();
  2. someVector.add("Hi there!");
  3. String someString = someVector.elementAt(0);
  4.  
Sep 4 '07 #5
JosAH
11,448 Expert 8TB
I changed the thread title but I still have no idea if it reflects what the OP needs.

kind regards,

Jos
Sep 4 '07 #6
r035198x
13,262 8TB
I changed the thread title but I still have no idea if it reflects what the OP needs.

kind regards,

Jos
Stumped me as well that's why I'd left it like that.
Sep 4 '07 #7
JosAH
11,448 Expert 8TB
Stumped me as well that's why I'd left it like that.
I'm afraid this is one of the many threads that become forgotten threads. It happens
all the time; quite disappointing if you'd ask me: an OP asks a vague question;
people try to help and ask further questions and then: void, silence, the abyss;
I wonder if the OPs are happy with it ...

kind regards,

Jos
Sep 4 '07 #8
I'm afraid this is one of the many threads that become forgotten threads. It happens
all the time; quite disappointing if you'd ask me: an OP asks a vague question;
people try to help and ask further questions and then: void, silence, the abyss;
I wonder if the OPs are happy with it ...

kind regards,

Jos
However, someone randomly surfing through the forums (myself), may find the responses very helpful.

Thanks!
Sep 4 '07 #9
Nepomuk
3,112 Expert 2GB
However, someone randomly surfing through the forums (myself), may find the responses very helpful.

Thanks!
Well, that's at least one person we've helped! ^^
Sep 5 '07 #10
how to pass string as vector object

If u want to pass the String value as Vector object, like this

Expand|Select|Wrap|Line Numbers
  1. String name = "ravinttf32";
  2. java.util.Vector vector = new java.util.Vector();
  3. vector.addElement(name);
  4. request.setAttribute("sendreqvector",vector);
otherwise, if u want to pass the vector Element as String object, like this

Expand|Select|Wrap|Line Numbers
  1. java.util.Vector vector = (java.util.Vector)request.getAttribute("sendreqvector");
  2. String name="";
  3. for(int i=0;i<vector.size(); i++)
  4. {
  5.      name = String.valueOf(vector.elementAt(0));
  6. }
  7. request.setAttribute("sendreqname",name);
Is it clear...
Sep 5 '07 #11

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

Similar topics

1
by: Rich | last post by:
HI, I am working on a program which implements the simplex aglorithm. I have decided to use a vector of vectors to set up my matrix. My initial thought was to fill the row vector with type...
19
by: chris | last post by:
Hello, I've recently been trying to understand the various structures supplied by c++, and the one I find most confusing is deque. One quick question about this. It seems most implementations...
1
by: Dekker | last post by:
Hi I would like to transform the result of a csv-string (eg.: "name,age\nstring,int\nMac,23\nMax,24\nMike,78") into a map of vectors map<string, vector<???> >. The key of the map will be the...
2
by: Ben Wheare | last post by:
Hiya, I'm fairly new to C++, and trying to figure out how to do the following: I have a class, strings, which has a private char array. To add to this array, I call the member function...
1
by: pallav | last post by:
I am writing a logic simulator for boolean circuits. I have a textfile which will contain vectors like this abc 001 100 111 ... I want to be able to bit pack these vectors to get a = 110, b...
5
by: andrewmorrey | last post by:
Hello, I've got a VC++ project containing multiple classes and a main function. In one of the class functions, it reads from a text file and places the data into a vector; //...
3
by: flavourofbru | last post by:
Hi, I know how to read a text file into a vector by using strings. Now i need to append an integer to the end of the text file. And then add one more vector elements to the end of the text file....
3
by: mersinli | last post by:
Hello; I will use standard library vectors and implement simple map coloring algorithm. The goal of a map coloring problem is to color a map so that regions sharing a common border have...
4
by: Caudata | last post by:
I am by no means an experienced c++ programmer, but I am trying to use a vector of vectors because it is convenient to store some strings while parsing a text file. I am having trouble with the...
2
by: Ushario | last post by:
Hi, I need to make a vector that will store a bunch of names for a random name generator. I need to know if I can use a vector to store strings instead of chars. Like this: std::vector<std::string>...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.