How do I get back a vector? I tried:
import oz.*;
Iterator v = getVector();
//but it gives me error says:
Method getVector not found in this class.
Then i tried:
Iterator v = oz.getVector();
//the error is:
Undefined variable, class, or package name: oz
under directory oz/checkout.java, I have:
private Vector cart = new Vector();
public Memory(String id) {
this.id = id;
cart.addElement(id);
}
public Iterator getVector() {
return cart.iterator();
}
-
How to get back the vector? (2 messages)
- Posted by: shelby tan
- Posted on: July 21 2002 06:29 EDT
Threaded Messages (2)
- How to get back the vector? by Lasse Koskela on July 22 2002 02:42 EDT
- How to get back the vector? by Sanil Pillai on July 22 2002 15:08 EDT
-
How to get back the vector?[ Go to top ]
- Posted by: Lasse Koskela
- Posted on: July 22 2002 02:42 EDT
- in response to shelby tan
The method <code>getVector()</code> has been defined as a member operation, that is, a method belonging to an instance, an object, instead of a class.
<p>
A member operation shall only be called referring to an instance, e.g. <code>myObj.getVector()</code>.
<p>
So, in order for the first code block to work, the <code>Iterator v = getVector()</code> must be located within one of the <code>checkout</code> classes member operations. -
How to get back the vector?[ Go to top ]
- Posted by: Sanil Pillai
- Posted on: July 22 2002 15:08 EDT
- in response to shelby tan
This is what you need to do :
Checkout checkoutObj = new Checkout();
Vector v = checkoutObj.getVector();
This is because getVector is a member method of the Checkout class .