Answers for "how to export a random char from string"

1

create a random char java

import java.util.Random;

public class RandomChar {
    public static void main(String[] args) {
        Random random = new Random();

        char randomizedCharacter = (char) (random.nextInt(26) + 'a');
        System.out.println("Generated Random Character: " + randomizedCharacter);

    }

}
Posted by: Guest on April-17-2021
0

A random character from a string of characters:

String chars = "abcxyz";
Random rnd = new Random();
char c = chars.charAt(rnd.nextInt(chars.length()));
Posted by: Guest on December-19-2020

Code answers related to "how to export a random char from string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language