How to call one function among many other functions randomly in Java ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 3

How to call one function among many other functions randomly in Java ?

25th Mar 2019, 10:36 AM
Satyam Deshmukh
Satyam Deshmukh - avatar
2 Respostas
+ 6
If the functions/methods were in different objects that inherited from the same class and you were allowed to use/override the same method name in the objects, you could probably store the objects in a collection like an array, get a random array index number and call the corresponding object's method, thereby calling a random/different method each time.
27th Mar 2019, 3:56 AM
Sonic
Sonic - avatar
+ 1
what do you exactly mean? you can call a function by jusr writing the functions name with (); e.g. myfunction();
25th Mar 2019, 9:27 PM
gabrijel2503