Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Vector problems

 
Vanessa Laffoon
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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
 
Billybob Marshall
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic