rand function in java code example Example: funzione random in java int n = (int) (Math.random() * 51);