Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

public class Main {
    static char digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

    public static char randomDecimalDigit() {
        return digits[(int) Math.floor(Math.random() * 10)];
    }

    public static String randomDecimalString(int ndigits) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < ndigits; i++) {
            result.append(randomDecimalDigit());
        }
        return result.toString();
    }

    public static void main(String[] args) {
        System.out.println(randomDecimalString(24));
    }
}