Android Build a Simple Android App Basic Android Programming Using the Random Class

new randomGenerator

Random randomGenerator; random. randomGenerator = new randomGenerator();

Hie guys where am i getting my code wrong here. Iam trying to initialize a new random generator

1 Answer

james south
james south
Front End Web Development Techdegree Graduate 33,252 Points

you are close. the syntax for declaring is Type varName; to initialize it is varName = new Type(); to do it in one line would be Type varName = new Type(); Random is your type and randomGenerator is your varName.

This is my question

initialize a new Random variable called randomGenerator. Hint: Don't forget to use the new keyword.

This is my answer

Random randomGenerator = new Random();

i still cant get it correct