JAVA 12 days of Christmas With 2 switches and 2 for loops
Go to solution
Solved by Mr_KoKa,
Ok, so I made a mistake explaining how you can do that in the post before, so I corrected it and now it is ok. You don't use inner loop, just switch, that has cases in reverse order and without any breaks, look at example above, it does it. I cannot edit last post, so there is example without new lines:
switch (i){ case 3: System.out.print('c'); case 2: System.out.print('b'); case 1: System.out.print('a'); }
for i = 1 it will display:
a
for i = 2 it will display:
ba
for i = 3 it will display:
cba
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now