how to do a function activate when some variable change in java : I need to activate a function when a variable change, it will be to do an update. EX:

public class Main{

private a = 1;

private ch = false;

private update(){
if(a % 2 == 0){ch = true;}

}

public static void main(String[] args){

a = 2;
}

  }