// simple while loop example
public class WhileLoop{
public static void main(String[] args) {
//learning
int a = 1;
while (a <= 5) {
System.out.println(" "+a);
a++;
}//exploring
int sum = 0, b = 1;
while (b <= 5) {
sum += b;
b++;
}
System.out.println("\nSum of 1-5 is " + sum);}
}
Output:1 2 3 4 5
Sum of 1-5 is 15