Returns a random digit [ 0-9 ]. - Android java.util

Android examples for java.util:Random

Description

Returns a random digit [ 0-9 ].

Demo Code


//package com.java2s;

import java.util.Random;

public class Main {
    /**//  www .  j  a v a  2 s.  c o m
     * Returns a random digit [ 0-9 ].
     */
    public static char randomDigit() {
        Random r = new Random();
        return (char) (r.nextInt(10) + '0');
    }
}

Related Tutorials