• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Vector problems

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all. I need some help with Vector.

I have a Vector:
Vector oneDimArray = new Vector();
That I'm trying to get to do this for loop:

for (int counter1 = 0; counter1 < 10; counter1++)
{
oneDimArray = counter1 + (" ");
}

and I'm getting an error on incompatible types. String was found but Vector is required (it points me to the + inside the for loop). How do I get the Vector oneDimArray to accept the new value of the string counter1 + (" "); ?
Btw, I'm a webdesign major, emphasis on design, lol, I don't have a logical bone in my body but am forced to take Java Maybe I'd be better at it if I wasn't forced to take it.
Vanessa
 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oneDimArray.add(String.valueOf(counter1));
- or -
oneDimArray.add(new Integer(counter1));
depending on what you really want to put in that vector - String-ified integers, or Integers.
 
Vanessa Laffoon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Woohoo! Thank you so much.. I've been frustrated with this for a week now.. I hate this class because the instructors know Java so well, they can't teach it.. They give us the barest overview then expect those of us who have never had any programming before to be able to understand it and dechiper the API.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic