mardi 27 janvier 2015

Why is my 2nd if statement in Java not working? [duplicate]


This question already has an answer here:




Good morning!


The goal of my code is to generate all possible three character strings that include A-Z and 0-9. For example, I want all possibilities from AAA to 999.


Problem: My own code will only output up to A99. My 2nd if statement is not generating the next step, which is confounding me. I need the 2nd if statement to work so that the A in A99 will increase to BAA and keep going.


Here is my code:



{
public static void main(String args[]) {

String[] AZ09 = {"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"};

while (z < AZ09.length) {
System.out.println(AZ09[x]+AZ09[y]+AZ09[z]);
z++;
if (AZ09[z] == "9") {
System.out.println(AZ09[x]+AZ09[y]+AZ09[z]);
y++;
z = 0;
}
if (AZ09[y] == "9" && AZ09[z] == "9") {
System.out.println(AZ09[x]+AZ09[y]+AZ09[z]);
x++;
y = 0;
z = 0;
}
}


Solution? Thoughts?


Please don't post as duplicate. I tried the .equals() method and still no dice


Thank you so much!


Aucun commentaire:

Enregistrer un commentaire