how to pass string as vector object
Vectors as Strings
Collapse
X
-
Tags: None
-
That cast will fail miserably; even the compiler can detect that. Maybe you mean:Originally posted by dmjproOr, [B(String)new Vector()[/B].
Kind regards,
Dmjpro.
[code=java]
(new Vector()).toStr ing();
[/code]
... which doesn't do anything useful either.
kind regards,
JosComment
-
Or maybe you mean:Originally posted by JosAHThat cast will fail miserably; even the compiler can detect that. Maybe you mean:
[code=java]
(new Vector()).toStr ing();
[/code]
... which doesn't do anything useful either.
kind regards,
Jos
[CODE=java]String someString = (String) Vector.elementA t(i);[/CODE]
However, if you're using Java 1.5 or later, just use the Vector like this:
[CODE=java]
Vector<String> someVector = new Vector<String>( );
someVector.add( "Hi there!");
String someString = someVector.elem entAt(0);
[/CODE]Comment
-
I'm afraid this is one of the many threads that become forgotten threads. It happensOriginally posted by r035198xStumped me as well that's why I'd left it like that.
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,
JosComment
-
However, someone randomly surfing through the forums (myself), may find the responses very helpful.Originally posted by JosAHI'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
Thanks!Comment
-
Originally posted by ravinttf32how to pass string as vector object
If u want to pass the String value as Vector object, like this
otherwise, if u want to pass the vector Element as String object, like thisCode:String name = "ravinttf32"; java.util.Vector vector = new java.util.Vector(); vector.addElement(name); request.setAttribute("sendreqvector",vector);
Is it clear...Code:java.util.Vector vector = (java.util.Vector)request.getAttribute("sendreqvector"); String name=""; for(int i=0;i<vector.size(); i++) { name = String.valueOf(vector.elementAt(0)); } request.setAttribute("sendreqname",name);Comment
Comment