Stupid Programmer at work!
Code:
public class Test {
char[] array = {'a', 'b', 'c', 'd'};
public void run() {
for (int a=0; a<array.length; ++a) {
for (int b=0; b<array.length; ++b) {
for (int c=0; c<array.length; ++c) {
for (int d=0; d<array.length; ++d) {
System.out.println(array[a] + ""
+ array[b] + "" + array[c] + "" + array[d]);
}
}
}
}
}
public static void main(String[] args) {
Test test = new Test();
test.run();
}
}
Stupid programmer, that's me. I am coding a program to print out a 8 char password program, containing uppercase, lowercase alphabets, digits and special chars like @#!$%^. I have coded a prototype to test out my idea, it seems to work, but at this rate i will be coding 8 stupid for loops to get the job done. Is there any other way to optimize/simplify how it can be done?
:p