The Artima Developer Community
Sponsored Link

Java Answers Forum
how can I get back the vector?

1 reply on 1 page. Most recent reply: Jul 21, 2002 8:26 PM by Singh M.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
shelby

Posts: 1
Nickname: shelby
Registered: Jul, 2002

how can I get back the vector? Posted: Jul 21, 2002 3:41 AM
Reply to this message Reply
Advertisement
I have a java bean under directory oz/a3/Memory.java
This memory.java will add element to a vector and it has:

package oz.a3;

private Vector cart = new Vector();

public Memory(String id) {
this.id = id;
cart.addElement(id);
}

public Iterator getVector() {
return cart.iterator();
}

So i have this page call checkout.java, that, when customer checkout, his items will be stored in vector, using the above bean. It looks like:


import oz.a3;
...
...
for (; enum.hasMoreElements(); ) {
String name = (String)enum.nextElement();
String[] arr = (String[])session.getAttribute(name);
String desc = arr[1];
String id = arr[0];
Memory v = new Memory(id); // Add ID into vector
}

Then in manager.java, i want to retrieve the vector.
How do I retrieve? Is it something like?

import oz.a3;

Iterator folio = getVector();
//but it gives me error says:
Method getVector not found in this manager.

Then i tried:
Iterator v = oz.a3.getVector();
//the error is:
Undefined variable, class, or package name: oz

So how should I get back the vector?


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: how can I get back the vector? Posted: Jul 21, 2002 8:26 PM
Reply to this message Reply
You have a few problems in your code...

1. There is no method in you class memory which will return a Vector. So, how can you get a vector if there is no method to retrieve it.

2. The method getVector belongs to class memory (not Manager) and you are simply calling getVector from Manager without any instance of memory!!!

Hope this helps.

Flat View: This topic has 1 reply on 1 page
Topic: How to avoid Memory Leaks in JAVA? Previous Topic   Next Topic Topic: getting ioexception when closing stream in applet WHY!!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use