java - Passing a string between voids -
i'm new java , i'm not sure if ask question right. have 2 voids, in second 1 string , want use main void. code that:
public void oncreate(bundle savedinstancestate) { shuffle(); //here want use string correctanswer } public void shuffle() { string correctanswer = "whatever"; }
if want use string calculated in second function, why use void?
public void oncreate(bundle savedinstancestate) { string s = shuffle(); //use s; } public string shuffle() { string correctanswer = "whatever"; return correctanswer; }
you make correctanswer instance variable:
private string correctanswer; public void oncreate(bundle savedinstancestate) { shuffle(); //use instance variable correctanswer; } public void shuffle() { correctanswer = "whatever"; }
Comments
Post a Comment