请用Java实现一个算法:由a-z、0-9组成3位的字符密码,并打印所有可能的密码组合。
作为初学者,以下实现方法可能笨拙或有误,希望有大神看到后给予优化和指点!~
public class Password {
public static void main(String[] args) {
char[] word = new char[]{'a','b','c','d','e','f','g','h','i','g','k','l'
,'m','n','o','p','q','r','s','t','u','v','w','x',
'y','z','1','2','3','4','5','6','7','8','9','0'};
char [] password = new char[3];
for (int i = 0;i <= 35;i++) {
password[0] = word[i];
for (int j = 0;j <= 35;j++) {
password[1] = word[j];
for (int k = 0;k <= 35;k++) {
password[2] = word[k];
System.out.println(Arrays.toString(password));
}
}
}
}
}