Forums Register Login

Problems with vectors

+Pie Number of slices to send: Send
What's wrong with this vector/iterator code? When it was coded as an array, it was ok. Everything compiles ok till here:

Here's the error message:

Thanks.
+Pie Number of slices to send: Send
Did you remember to import java.util.*?
Did you use JDK 1.2 and above?
+Pie Number of slices to send: Send
Ok, got it down to one error, but can't figure it out.

The error code now:

getSize() is a method defined in class MemoryChip, which is in the same package and which is referenced in several other places in this class w/o problem.
The vector here holds MemoryChip objects. My thinking is that (chip.next()) should refer to an element in the vector of type MemoryChip, and so return getSize(). Doesn't work. Thanks for the help.
[ April 03, 2002: Message edited by: Greg Adams ]
+Pie Number of slices to send: Send
Are you sure the case is correct?
In the compiler error, I see a getsize (lowercase 's') and you are talking about getSize (uppercase 's'). May that be the reason?
+Pie Number of slices to send: Send
Your Iterator.next() method returns an "Object" type. You have to cast it back to "MemoryChip" before the compiler can check the "getsize()" method for you.
Try this:
totalRam += ((MemoryChip) chip.next()).getsize();
[ April 03, 2002: Message edited by: Michael Yuan ]
+Pie Number of slices to send: Send
Thank you both, that cleared up the problem.
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 900 times.
Similar Threads
error when testing...any help will be appreciated
Using the drawoval method
My first interface
Graphics2D compiler error
What is wrong with this code?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 05:17:06.