Testing out a simple while loop but I'm confused, if bottle is 1,name is "bottle". But even when bottle is greater that 1, it still prints bottle and not bottles
public class ex {
public static void main(String[] arg) {
int bottle = 0;
String name = "bottles";
while (bottle < 100) {
if (bottle == 1) {
name = "bottle";
}
System.out.println(bottle +" "+ name);
++bottle;
}
}
}
Aucun commentaire:
Enregistrer un commentaire