do-while loop in Java
In Java, do-while loop is similar to while loop, however there is a difference between them: In while loop, condition is evaluated before the execution of loop’s body but in do-while loop condition is evaluated after the execution of loop’s body. ``` public class Main { public static void main(String[] a) { do { int x = 10; } while (x > 0); // x is defined in do block; access it from while results a compile time error. } } ```