hi,
i have a midlet which has got a static variable. i need to keep the record of all the instances created in this variable. but it does not work like static variable. my code segments look like this. i am running this midlet on sun wireless toolkit 2.5.5. i can create many objects of same midlet from that toolkit but still my counter shows only 1.
public class SMS extends MIDlet implements CommandListener {
private Display display; private TextField userID, password ; public static int counter ;
public SMS() {
userID = new TextField("LoginID:", "", 10, TextField.ANY);
password = new TextField("Password:", "", 10, TextField.PASSWORD);
counter++;
}
public void startApp() {
display = Display.getDisplay(this);
loginForm.append(userID);
loginForm.append(password);
loginForm.addCommand(cancel);
loginForm.addCommand(login);
loginForm.setCommandListener(this);
display.setCurrent(loginForm);
public void commandAction(Command c, Displayable d) {
String label = c.getLabel();
System.out.println("Total Instances"+counter);
everytime, counter shows only 1 object created. please, help me out