-
For loop
i wan to print out a list of all the possible passwords of 8 characters
here is my codes but i duno whats the error... any suggestions?
public class password {
public static void main (String args[]) {
char list[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
'w','x','y','z','0','1','2','3','4','5','6','7','8','9','(',')',
'[',']','<','>','{','}','+','=','@','#','$','%','!','&','*','?'
};
for (a=0; a<80; a++) {
for (b=0; b<80; b++) {
for (c=0; c<80; c++) {
for (d=0; d<80; d++) {
for (e=0; e<80;e++) {
for (f=0; f<80; f++) {
for (g=0; g<80; g++) {
for (h=0; h<80; h++) {
system.out.print(char[a]);
system.out.print(char[b]);
system.out.print(char[c]);
system.out.print(char[d]);
system.out.print(char[e]);
system.out.print(char[f]);
system.out.print(char[g]);
system.out.println(char[h]);
}
}
}
}
}
}
}
}
}
}
-
Hey Man,
The problem is that the system class is not found. The reason being the naming convention. You gotta follow the naming conventions. All the class names in java starts with Caps. So , your "system.out.print" should be "System.out.print".
Also, your class name (password) should start with a Caps. Better use Password.
Good Luck :-)
Narayana
-
Actually I found lot many changes. Please find the revised code. A suggestion for you is to develop your basic skills. The reason being the usage of the char variable in the program. Instead of using the variable list, you used the keyword char and thats the reason for the errors.
public class Password {
public static void main (String args[]) {
char list[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V',' W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s' ,'t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','(',')','[',']','<','>','{','}','+','=','@','#','$','%','!','&','*','?'};
for (int a=0; a<80; a++) {
for (int b=0; b<80; b++) {
for (int c=0; c<80; c++) {
for (int d=0; d<80; d++) {
for (int e=0; e<80;e++) {
for (int f=0; f<80; f++) {
for (int g=0; g<80; g++) {
for (int h=0; h<80; h++) {
System.out.print(list[a]);
System.out.print(list[b]);
System.out.print(list[c]);
System.out.print(list[d]);
System.out.print(list[e]);
System.out.print(list[f]);
System.out.print(list[g]);
System.out.println(list[h]);
}
}
}
}
}
}
}
}
}
}
-
Actually I found lot many changes. Please find the revised code. A suggestion for you is to develop your basic skills. The reason being the usage of the char variable in the program. Instead of using the variable list, you used the keyword char and thats the reason for the errors.
public class Password {
public static void main (String args[]) {
char list[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V',' W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s' ,'t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','(',')','[',']','<','>','{','}','+','=','@','#','$','%','!','&','*','?'};
for (int a=0; a<80; a++) {
for (int b=0; b<80; b++) {
for (int c=0; c<80; c++) {
for (int d=0; d<80; d++) {
for (int e=0; e<80;e++) {
for (int f=0; f<80; f++) {
for (int g=0; g<80; g++) {
for (int h=0; h<80; h++) {
System.out.print(list[a]);
System.out.print(list[b]);
System.out.print(list[c]);
System.out.print(list[d]);
System.out.print(list[e]);
System.out.print(list[f]);
System.out.print(list[g]);
System.out.println(list[h]);
}
}
}
}
}
}
}
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks