Check out example codes for "dice in java". It will help you in understanding the concepts better.

Code Example 1

/*
Author: Jeffrey Huang
[email protected]
This is a simple code that uses math.random 
to generate a number from 1-6, inclusive.
*/
import java.util.Random;
public class Main
{
	public static void main(String[] args) {
	    int i;
	    i = (int)(6*Math.random()+1);
		System.out.println(i);
	}
}

Learn ReactJs, React Native from akashmittal.com