¿Cómo crear una variable global en una aplicación Eclipse PDT?

I have an Eclipse PDT applicaction and I want/need to use a global variable that can be retrieved everywhere in the app.

I need a sort of "last_client" o "last invice" to let the application be more "agile" when the user goes from one screen to another. It's difficult to explain without an example, but basically I need a global variable so when teh application creates a combo for letting the user select an entities , the combo will be default to that global variable if is set.


preguntado el 09 de marzo de 12 a las 14:03

1 Respuestas

Just refer to that class.that variable. Assuming the class is called "invoice" and the variable is called "user" it would look like:

lastUser = invoice.user;

You'd need to make the variable public to access it from a different class. If you want it to be private (and you should!) You'll need to create a getter method for it. Like:

public String returnUser()
return user;

And you'd call it from the other class like:

lastUser = invoice.returnUser;

¡Espero que sea útil!

respondido 09 mar '12, 14:03

close .. what I need is to store in the application the "lastUser" variable. I created a property in Activator class, and create getters and Setter, but I don't know if is the right way - Nicolas400

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.