| Author |
Problems with vectors
|
Sal Velinus
Greenhorn
Joined: Mar 05, 2002
Posts: 25
|
|
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.
|
 |
Michael Yuan
author
Ranch Hand
Joined: Mar 07, 2002
Posts: 1427
|
|
Did you remember to import java.util.*? Did you use JDK 1.2 and above?
|
Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
|
 |
Sal Velinus
Greenhorn
Joined: Mar 05, 2002
Posts: 25
|
|
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 ]
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
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?
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
Michael Yuan
author
Ranch Hand
Joined: Mar 07, 2002
Posts: 1427
|
|
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 ]
|
 |
Sal Velinus
Greenhorn
Joined: Mar 05, 2002
Posts: 25
|
|
|
Thank you both, that cleared up the problem.
|
 |
 |
|
|
subject: Problems with vectors
|
|
|