hi please help to print character form a-z and 0-9 randamly in java all the character sholud be present without repetion ie all 26+10 letter sholud print and each time it sholud print differently like First time if it print like this 0 a 2 f g t h y j q 3 v ......
next time f r v c 3 b 5 h 6 j 6................like this
please help me to get this type of result... and i want to store that in a table using Applet

Dani AI

Generated

Short note: the goal is a single random permutation of the 36 symbols (a–z, 0–9) with no repeats, then show/store that permutation in a table inside your applet. ’s pick-and-remove idea is sound and confirmed it works. For a compact, fast, and provably uniform result I recommend an in-place shuffle (Fisher–Yates): it gives a true random permutation in O(n) time and avoids extra shifting or many allocations.

A compact Java implementation that builds the character set and does Fisher–Yates:

static char[] randomPermutation(Random rnd) {
    char[] a = new char[36];
    int k = 0;
    for (char c = 'a'; c <= 'z'; c++) a[k++] = c;
    for (char c = '0'; c <= '9'; c++) a[k++] = c;
    for (int i = a.length - 1; i > 0; i--) {
        int j = rnd.nextInt(i + 1);
        char t = a[i]; a[i] = a[j]; a[j] = t;
    }
    return a;
}

To display the result in a Swing table (JTable) you can push the characters into a DefaultTableModel and show that model in a JScrollPane. If you need persistence, don’t attempt filesystem writes from an unsigned applet — either send the sequence to a server endpoint (HTTP POST) or use a signed applet (legacy) or, better, move to a small Swing application or a web front end.

Troubleshooting tips: seed Random when you want repeatable sequences for testing; use SecureRandom only when cryptographic unpredictability is required; verify you really want lowercase letters and digits (adjust the ranges if not). Given modern browser environments, consider replacing the browser applet with a lightweight GUI or web UI if you expect others to run this code today.

Recommended Answers

All 3 Replies

Make an arraylist with all the individual items.

Generate a random number (not larger than the current size of the arraylist) and get then remove that index from the arraylist. Repeat.

thanks its working now

String[] str={"a","y","z","0","1","2","3","4"};
List<String> list=new ArrayList(Arrays.asList(str));
System.out.println( Collections.shuffle(list));

u wil get the out put each time differntly....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.