• 18 May

    Fill Array With Random Numbers in Java

    The arrays are a commonly used data structure that stores the data in contiguous memory. In this article, you will understand different methods to fill the array with random numbers in Java. We will generate the random numbers using different library methods such as the Java Utility library’s Random class, the Java’s Math class, and […]

  • Java random number between 1 and 100
    07 March

    Random Number Between 1 and 100 in Java

    TL;DR To generate random number between 1 and 100 in java, you can use Math.random() method. [crayon-6729aeb7e9e28232073145/] Output: Random number between 1 and 100: 26 Math.random Java between 1 and 100 Java provides the Math class to perform all sorts of mathematical operations. The class also has a method named random() that produces pseudo-random numbers […]

  • 05 October

    Get Random Number between 0 and 1 in Java

    In this post, we will see how to get random number between 0 to 1 in java. We have already seen random number generator in java. Get Random Number between 0 and 1 in Java We can simply use Math.random() method to get random number between 0 to 1. Math.random method returns double value between […]

  • 30 March

    java random number between 1 and 10

    We have already seen random number generator in java.In this post, we will address specific query on how to generate random number between 1 to 10. Using random.nextInt() to generate random number between 1 and 10 We can simply use Random class’s nextInt() method to achieve this. As the documentation says, this method call returns "a […]

  • 13 December

    Java Random nextDouble

    In this tutorial, we will see Java Random nextDouble method.It is used to generate random double. It returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator’s sequence. Syntax [crayon-6729aeb7ea1de377364796/] Here random is object of the java.util.Random class. Return returns random double. Example Let’s understand with the help […]

  • 13 December

    Java Random nextInt

    In this tutorial, we will see Java Random nextInt method.It is used to generate random integer. There are two overloaded versions for Random nextInt method. nextInt() Syntax [crayon-6729aeb7ea2b9730452632/] Here random is object of the java.util.Random class. Return returns random integer. Example Let’s see a very simple example: [crayon-6729aeb7ea2bc927331286/] Output: Random Integer: 1326186546 Random Integer: 203489674 […]

  • 13 December

    Java – generate random String

    In this tutorial, we will see how to generate random String in java. There are many ways to generate random String.Let’s explore some of ways to generate random String. Using simple java code with Random You can use SecureRandom class to generate random String for you. Let’s understand with the help of example. [crayon-6729aeb7ea38d025575659/] Output: […]

  • 13 December

    Random number generator in java

    In this tutorial, we will see about random number generators.You might have requirement where you want to generate random numbers to perform some operation. For example: Let’s say you are creating a game which uses dice for each player’s turn. You can put logic to generate random number whenever the player uses dice. There are […]