How do I pull object information out of a vector.
I started in VB, and am now developing with java, so I'm finding small trip-ups which are to be expected.
Anyways, I'm trying to get an object element from an object in a vector.
I tried this, but it wouldn't return the "Name" query method:
System.out.println(myvector.get(0).Name.toString);
The object is a "Product" which I made the class for and everything. I even tried using typecast with no avail:
System.out.println((Product)myvector.get(0).Name.toString);
This is prolly one of the most basic things, yet I've found nothing on object attribute retrieval from a vector on google and wikipedia for that matter.
[663 byte] By [
zensunnia] at [2007-11-26 15:53:10]

Thanks for the help, but I must just be slow or something...
Apparently I don't know how to create a function either and I don't want to create another thread to ask....
Now, I need a function to accept the Vector, manipulate it, and return a double.
Something like this:
public double getSumOfProductPrice(Vector productvector)
{
<manipulate productvector>;
return <result>;
}
I dunno, but everything I type gives me red lines.
Message was edited by:
zensunni
> Now, I need a function to accept the Vector,> manipulate it, and return a double.Alright. How do you want to manipulate it, and what do you want to return. Your question is very vague.
Yea, it is..sorry
The Product class looks like this:
public class Product
{
private int mProductID;
private String mName;
private double mPrice;
private int mQuantity;
// Update Methods
public void ProdID(int id) {mProductID = id}
public void Quantity""
etc
etc
// Query methods
public int ProdID() {return this.mProductID;}
etc
etc
}
Basically, I want a function in my main class to accept a Vector filled with product objects and calculate a sum of all the products and return a double type value.
I'm fine with manipulating the vector, I just don't know how to state the function.
Message was edited by:
zensunni