1.Random
class Random implements java.io.Serializable
Here is the code for a simple captcha:
public static void main(String[] args) { // Do a simple verification code char [] charr = {'q','Q','F','f','d','kind',' in','over' }; String str = ""; Random random = new Random(); for(int i = 0; i < 4; i++) { str + = charr [random.nextInt (charr.length)]; } System.out.println(str); }
Note: nextInt calls this method to return the specified range of data of type int
If you want to call other types, you only need to call the corresponding method