is there another way of solving this?
Justin Wahe
Level 4
I used a for loop but
Under discussion
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Tuấn Trần
1 April 2020, 04:27
Use for loop to solve that.
Hope this help. 0
green
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. ;)
0
Misiu
19 March 2020, 18:30
Yes, another loop: while, do...while.
Or just four the same instructions. One under another.
0