• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem!

 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I would like to know how can I get a vector (or an array of strings) that is returned from a method in order to apply operations on them...
Please help.
Regards,
MAC.
 
xavier romea
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to return a Vector, it's easy
public Vector functionName (){
Vector result = new Vector();
return result;
}
or an array of String
public String[] functionName(){
String result[];
return result;
}
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
problem is that I was trying to assign a vector to another vector of may be different sizes.
so I needed to intialize vector as follows:
Vector vector = new vector(0);
Regards,
MAC.
 
Mo Ibrahim
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jimi,
Vectors come handy when they are of different sizes or unknown sizes. You don't have to initialize them. Just assign.
-mo
 
Jimi Rock
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mo, I dont know why I didnt think this way although I used to assign strings many times as you have specified.
When we initialize a vector as :
Vector vector = new Vector();
size will be 10 intially.
but when we initialize size by Vector(0), then size is going to be incremented starting from 0 each time we add an element.
Problem is solved any way...
Thanks for all.
Regards,
MAC.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!