我在FourActivity中创建了一个公共变量并在FinalActivity类中访问它,但变量的值总是显示为0.我已经在FourActivity类中创建了一个返回整数的getRandomNumber函数。
public int i;
i=getRandomNumber(); //
Now i am accessing variable i in FinalActivity Class through this way
FourActivity fourActivity=new FourActivity();
int randomNumber=fourActivity.i;
Toast.makeText(FinalActivity.this,"Random Number" +randomNumber ,Toast.LENGTH_SHORT).show();