Tuesday, February 16, 2021

Get specific length random number in Java

Get specific length random number in Java:

import java.util.Random; 

public class RandomJavaProgram {
   public static void main(String []args) {
       RandomNumber RandomNumberObj = new RandomNumber();
       System.out.println(RandomNumberObj.getRandomNumber(3));
   }
}

class RandomNumber {
    public String getRandomNumber(int digitLength) {
        int[] numberContainer = new int[digitLength];
        String mainRandomNumber = "";
        Random rand = new Random();

        for ( int i = 0; i < digitLength; i++ ) {
            numberContainer[i] = rand.nextInt(10);
        }        

        for ( int j = 0; j < digitLength; j++ ) {
            mainRandomNumber = mainRandomNumber + String.valueOf(numberContainer[j]);
        }       

        return mainRandomNumber;
    }
}

Difference between COPY and volume in Docker

Difference between COPY and volume in Docker:

Volume creates a mount point that the Docker host can interact with.
COPY too can accomplish that but it does that during build time.

With Volume, you can keep interacting with the contents on the host machine but COPY is just one time activity which is used during the build time.

Switch PHP version in Ubuntu OS or Zorin OS

First check where is installed your PHP by the below command: $ which php See PHP version by below command: $ php -v As I've installed P...