Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

fill an array with random numbers between 1 and 100 java

import java.util.Scanner;
import java.util.Arrays;


public class RndArray{
	public static void main(String[] args){
    
		Scanner scan = new Scanner(System.in);
        int arrLength;
        
		System.out.println("Enter your array's length");
		arrLength = scan.nextInt();
		int [] arr = new int [arrLength]; // between [] array's length

		for(int i = 0 ; i<arrLength ; i++){
        	arr[i] = (int) (Math.random()*100 + 1);
            }
         System.out.println(Arrays.toString(arr));
         }
}	
Comment

PREVIOUS NEXT
Code Example
Java :: java go troght loop object 
Java :: onclick listener android 
Java :: wait random time java 
Java :: recycler view implementation 
Java :: float maximum value java 
Java :: math.sin java 
Java :: close a popup selenium python 
Java :: toCharArray() method java 
Java :: java observer pattern 
Java :: Java Stack class pop() method 
Java :: string to bigdecimal 
Java :: date difference in minutes java 
Java :: object to int java 
Java :: android studio breakpoint not working 
Java :: java convert to roman numerals 
Java :: java cast int to string 
Java :: open camera or gallery on button click android 
Java :: java jtable change column color 
Java :: materialbutton remove shadow xml 
Java :: generate random password in spring boot 
Java :: java print 
Java :: filter arraylist java 
Java :: java create file in folder 
Java :: on selected item changed listview javafx 
Java :: map string string to java object 
Java :: create java gui intellij 
Java :: uppercase java 
Java :: write an infinite loop java 
Java :: scanner.hasnext() 
Java :: hadoop-master error java_home is not set and could not be found 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =