• 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

    Generate Random Number Between 1 and 100 in Java

    Oftentimes, as a Java programmer, you might need to generate random numbers in a particular range. Java provides several inbuilt libraries to perform this task. There are third-party libraries as well to generate the random numbers. This article discusses the following methods to generate random number between 1 and 100. Random class of Java Utility […]

  • 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. We can simply use Math.random() method to get random number between 0 to 1. Math.random method returns double value between o(inclusive) to 1(exclusive). [crayon-6289974e3ca3a170943506/] When you run above program, […]

  • 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-6289974e3fbca209112004/] 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-6289974e40667323605118/] Here random is object of the java.util.Random class. Return returns random integer. Example Let’s see a very simple example: [crayon-6289974e40672966492702/] 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-6289974e4191d130868160/] 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 […]