is there another way of solving this?
I used a for loop but
You must be signed in to leave a comment
1 April 2020, 04:27
Use for loop to solve that.Hope this help.
19 March 2020, 19:41
Like misiu said, there are multiple ways to do the same thing. I personally think the for loop is the best approach. But you could work with a while loop or do while loop as well. No to mention, if you didn't know how to work with loops then just copy/pasting the println() 4 times would work as well. In fact if you wanted to go even further then you could use recursion to solve this problem (though no recommended for something as simple as this). So there are tons of different solutions that would work. Its your job as a developer to figure out whats the best approach, what is less complex, and what is just plain easy to do. ;)
19 March 2020, 18:30
Yes, another loop: while, do...while. Or just four the same instructions. One under another.