java - How to fill an array with random numbers from 0 to 99 using the class Math? -


i wrote code, there no conversion double int.

public class array {     public static void main(string[] args) {         int i;         int[] ar1 = new int[100];         for(int = 0; <  ar1.length; i++) {             ar1[i] = int(math.random() * 100);             system.out.print(ar1[i] + "  ");         }     } } 

how can corrected?

it should like

 ar1[i] = (int)(math.random() * 100); 

when cast, cast type should in brackets e.g. (cast type)value


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -