Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Java でランダム パスワード ジェネレーターを作成していますが、プログラムでランダムな char 値を生成する方法について助けが必要です。何か案は?小文字、大文字など、生成するさまざまな種類のパスワードを表示する方法として、メニュー システムを使用しています。
どんなアドバイスも役に立ちます。
ありがとう!
Random r = new Random(); String alphabet = "123xyz"; // Prints 50 random characters from alphabet for (int i = 0; i < 50; i++) { System.out.println(alphabet.charAt(r.nextInt(alphabet.length()))); }
文字を出力する代わりに、それらを に追加するとStringBuilder、ランダムなパスワードが得られます。
StringBuilder
(ソース)