problem with update the counter value
Posted
by Edan
on Stack Overflow
See other posts from Stack Overflow
or by Edan
Published on 2010-05-03T13:18:52Z
Indexed on
2010/05/03
14:18 UTC
Read the original article
Hit count: 224
java
Hello,
I having problem to update the counter (integer value). this is the definitions of the class:
public class Item_Actions
{
private final int MAX_ITEMS = 100;
private Item myItem[];
private int counter;
public Item_Actions()
{
myItem = new Item[MAX_ITEMS];
counter++;
}
//Constructor add item into the menu (Description, type & price of Item)
public void addItem(Item itm)
{
myItem[counter] = itm;
counter++;
}.......
Now everytime I call the addItem constructor from another class, the counter always stays on zero. What causing it and how do I save the data inside?
thanks
© Stack Overflow or respective owner