Intro
This examples, will demonstrates how to use Do While Loop statement using Java program.
Examples
package com.freesamplecode.java.basic;
public class DoWhileLoopDemo {
public static void main(String[] args){
//print numeric value from 1 to 5
int i = 1;
do{
System.out.println(i);
i++;
}while(i < 6);
System.out.println("\n");
char[] chars = {'L','e','a','r','n','i','n','g'};
// print string learning using char array
int j = 0;
do{
System.out.print(chars[j]);
j++;
}while(j < chars.length);
}
}
Output
1 2 3 4 5 Learning

0 comments: