What's the purpose of "do...while" loop? Can't the same result be achieved with just "while" loop?
do while loop - Java Basic
Java do..while loops explained with examples - Guide - The freeCodeCamp Forum
Why don’t we see more use of the “do...while” loop?
do while is primarily used when you want to go through one iteration of the loop body. while do implies you might not execute the body at all. I wouldn't pick one over the other based on perceived efficiency. I would base it primarily on whether you know you'll do one iteration or not.
What are looping statements in Java
Can you nest loops in Java
What are the types of looping statements in Java
Videos
It seems like all the examples I've seen of "do...while" loop can be done with just "while" loop.
For example:
'''
var number = 6
var factorial = 1
do {
factorial *= number
number--
}while(number > 0)
println("Factorial of 6 is $factorial")
'''
is the same as
'''
var number_ = 6
var factorial_ = 1
while (number_ > 0) {
factorial_ *= number_
number_--
}
print ("factorial_ is $factorial_")
'''