The program will output random strings containing numbers [0-9] and letters [a-z,A-Z].
The numbers in the code map to UniCode characters (for a full Unicode chart see here).
An explanation of the code is as follows:
- Generate random numbers within the range 48 (unicode for 0) to 122 (unicode for z).
- Only allow numbers less than 57 (the digits 0-9) or greater than 65 and less than 90 (letters A-Z) or great than 97 (the letters A-Z).
- Map each number to a char.
- Stop when you have the required length of the string.
- Collect the chars produced into a StringBuilder
- Turn the StringBuilder in a String and return
For random.ints(48,122) upper bound should be 123, because it exclusive
ReplyDeleteAlso (i<57 || i>65) && (i <90 || i>97) should be
Delete(i < 58 || i > 64) && (i < 91 || i > 96)
finally, to avoid of unnecessary boxing and unboxing
Deleterandom.ints(48,123)
.filter(i -> (i < 58) || (i > 64 && i < 91) || (i > 96))
.limit(length)
.collect(StringBuilder::new, (sb, i) -> sb.append((char) i), StringBuilder::append).toString());
I found an example of a script for a random number generator on the Internet, but I wanted to study this topic in more
ReplyDeletedepth because in many my projects a random series exist and it will help to test the password or won accessed. I advise you to download random number generator java https://explainjava.com/random-number-generator-java/ and read the detailed article because simply copying the code, the effectiveness will of course be, but you'll not develop as a professional behind this.
Đặt vé tại phòng vé Aivivu, tham khảo
ReplyDeletemua ve may bay di my
chuyến bay đưa công dân về nước
chuyen bay nhat viet
bao giờ có chuyến bay từ đức về việt nam
giá vé máy bay từ canada về Việt Nam
Máy bay từ Hàn Quốc về Việt Nam
khách sạn cách ly ở tphcm