I would like to ask you how to generate random numbers with java ordered character values.

Asked 2 years ago, Updated 2 years ago, 27 views

Client to

If you press the button I provided on the Internet, You want a string and a random number to appear.

What I thought was

a123 . . . z123

Start with uppercase when lowercase ends

A123 . . . Z123

I want to make sure that lowercase letters come in when capital letters are over

aA123 . . . zZ123

When lowercase letters are finished, lowercase letters and uppercase letters are combined again

Aa123 . . . Zz123 The reason why we planned it this way is

I don't think it'll overlap if I think that's why Of course, I'm going to give you a random number.

I don't know what to do because I'm a beginner.

Can I get a hint?

java sql

2022-09-21 23:22

1 Answers

I don't know the purpose, but...Why don't we make a set of alphabets and numbers and shuffle that set to get results?

java.util.Collections.shuffle(List<?>) returns a random mix of List objects.

For example, if you put elements a~z, 0~9 in the list and shuffle, you will randomly mix them and return them. This allows you to create random values without worrying about duplication.


2022-09-21 23:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.