Android Build a Simple Android App Basic Android Programming Generating a Random Number

yadin michaeli
yadin michaeli
Pro Student 5,422 Points

fact = randomNumber im a little confused

Hi a little confused about this line of code: fact = randomNumber

does it mean that we set fact variable to randomNumber variable?

please explain that to me

1 Answer

Evan Demaris
Evan Demaris
64,249 Points

Hi Yadin,

Yes, that code indicates that we're assigning the fact variable to equal the random number generated by the randomNumber variable. We then concatenate the number with an empty string to coerce the number into a string without explicitly casting it as such, because fact is a String then assigned to a TextView.

Specifically, it's then assigned to mFactTextView to display that number. mFactTextView tells you that you have correctly gone from one random number to another as you click the mShowFactButton.

Hope that helps!