到目前为止,这是我的编码。我正在制作一个程序来帮助为用户随机创建密码。我在制作随机字母时遇到问题。我想到了一种方法,但它给了我一个不兼容的错误,我尝试了:
chars[] letters= "abecdefghijklmnopqrstuvwxyz".toCharArray();
这是我目前的代码。
import java.util.Random;
import java.util.Scanner;
public class Password
{
public static void main(String [] args)
{
char letters;
Scanner in = new Scanner (System.in);
System.out.println("Please choose from the following menu options:");
System.out.println("[1] Lowercase Letters");
System.out.println("[2] Lowercase & Uppercase Letters");
System.out.println("[3] Lowercase, Uppercase, and Numbers");
System.out.println("[4] Lowercase, Uppercase, Numbers and Punctuation");
System.out.println("[5] Quit");
System.out.println ("Enter Selection:");
int selection = in.nextInt();
System.out.println("Password Length (1-14):");
int length = in.nextInt();
if (selection == 1)
letters = "abcdefghisjklmnopqrstuvwxyz".toCharArray();
Stringbuilder sb = new StringBuilder();