Im trying to use an integer, that Im using in one class and also use the SAME int in a different class.
I forgot, what do I have to do for that?
static? implements? extends? what?
Best regards,
For simplicity:
public class ETBetaActivity extends Activity implements View.OnClickListener {
public static int anInt = 50;
Another class
public class GUI extends Activity implements View.OnClickListener {
public static int anInt_2 = 5+anInt;
staticis used to set that value to class, so all objects of the class will have that.example:
and you can access it like this:
FirstClass.yourIntYou should consider the following example, if you want to avoid static:
and from all the classes you can use this using getters and setters. Note that if you use 2nd method (with getter and setters ) you will have different values for
yourInt, for each object you create, and that value should be set on constructor .