Quick actions

cmd+k|ctrl+k

Navigation

Languages

JavaGenerateRandomInteger

Snippet info

Language

Java

Visibility

public

Author

masterhun

Created

2023-12-13T18:23:36.675904Z

Updated

2023-12-13T18:28:19.424719Z

class Main {
    public static void main(String[] args) {
        System.out.println("Hello World!");
        
        int min = 50; // Minimum value of range
        
        int max = 100; // Maximum value of range
        
        // Print the min and max  
        
        System.out.println("Random value in int from "+ min + " to " + max + ":");
        
        // Generate random int value from min to max
        
        int random_int = (int)Math.floor(Math.random() * (max - min + 1) + min);
        
        // Printing the generated random numbers
        
        System.out.println(random_int);
      
      
    }
}
INFO