I'm trying to print multiple random numbers for a give time using lettertest(num) I also need to return the number to set a new value for a old numer. How?
public static int timewait(int times){ // print Rand number
int num;
for(int i=0; i
What programming language is that ?
probably java, I haven't learnt about threads and catching exceptions yet, so not sure what try {...} does
@Tomas Basically, the code inside the try {} block is executed, but whenever an exception (in this case, the program is specifically expecting an InterruptedException) occurs within that block the catch {} block right after it will handle it, and therefore control will be transferred to the part inside the except {} block, instead of just having the entire program crash :-D
oops I meant the catch {} block in the last part of my explanation (I get confused since except is the keyword used in Python's try-except clauses)
anyway in this piece of code the try-except clause is just used so that the whole program doesn't crash in case something weird happens when calling Thread.sleep
so when exception comes it does nothing and just continues program?
yeah, notice the empty braces after the except()
oops I meant catch() :-P
it will always return 1 number or it won't work at all because I don't know such method Rand and I don't have idea what lettertest does
IS IT JAVA ?
It is definitely some kind of Java.
Join our real-time social learning platform and learn together with your friends!