• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem!

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic