You need to change the variable to the number 3:

private int step = 1; 

Using the static method:

  public static void onDoubleTap() { //-----Получить переменную и изменить её----- System.out.println("Переменная изменена на число 3"); } 

The static variable is not necessary!

  • 2
    This can be done only by passing an instance of the class to the method. Without this, the static method will not have access to the instance variable. Well, or make the variable itself static. And it is clearly not local to you, but the class field is YuriySPb
  • Yuri, can be more detailed how to transfer? - Twikoffin
  • one
    Well ... Type somehow so: public static void onDoubleTap(ClassName instance) { instance.step+=3; } public static void onDoubleTap(ClassName instance) { instance.step+=3; } then it will be necessary to cause so: ClassName.onDoubleTap(classNameInstance) . But it seems to me that you are trying to solve an unknown task in some wrong way. - Yuriy SPb
  • Thanks for the explanation, Yuri, I will try. - Twikoffin 7:42 pm
  • You are clearly trying to solve a problem with a crutch. It is best for you to describe the problem itself to be solved in order to get the right solution, and not your wrong idea about its solution. In general, there should be no static methods in android. - pavlofff

0