Table of Contents
In this article, we will discuss the concept of Print array elements using Do-while loop in Java
In this post, we are going to learn how to write a program to print in an array elements using do-while loop in Java language
In this code, we are going to learn how to display integer array elements in an array using do-while loop in Java language
Program 1
//Display integer of an array using while loop class Disp_Array_int_Dowhileloop{ public static void main (String args[]){ int arr[]=new int[]{113,611,119,111,167,118}; //declaration and initialization of an array System.out.println("Display elements of given array"); //do-while loop use to displays the elements by incrementing value of i int i=0; do{ System.out.println(arr[i]+" "); i++; }while(i<arr.length); } }
When the above code is executed, it produces the following result
Display elements of given array 113 611 119 111 167 118
In this code, we are going to learn how to display integer array elements in an array using do-while loop in Java language
Program 2
//Display integer of an array using do-while loop class Disp_Array_int_Dowhileloop1{ public static void main (String args[]){ int arr[]=new int[6]; arr[0]=1120; arr[1]=1310; arr[2]=1140; arr[3]=1510; arr[4]=1160; arr[5]=1710; //declaration and initialization of an array System.out.println("Display elements of given array"); //do while loop use to displays the elements by incrementing value of i int i=0; do{ System.out.println(arr[i]+" "); i++; }while(i<arr.length); } }
When the above code is executed, it produces the following result
Display elements of given array 1120 1310 1140 1510 1160 1710
In this code, we are going to learn how to display String array elements in an array using do-while loop in Java language
Program 1
//Java program to read and print string of an array using do-while class Disp_Array_of_String_doWhileloop{ public static void main (String args[]){ String str[]=new String[]{"Vietnam","Mexico","Turkey","Iran","France"}; //declaration and creation of an array System.out.println("\nYour strings are:"); int j=0; do{ System.out.println(str[j]); j++; }while(j<str.length); //display all entered string } }
When the above code is executed, it produces the following result
Your Strings are: Vietnam Mexico Turkey Iran France
In this code, we are going to learn how to display String array elements in an array using do-while loop in Java language
Program 2
//Java program to read and print string of an array using do-while class Disp_Array_of_String_doWhileloop1{ public static void main (String args[]){ String str[]=new String[5]; //diclaration and creation of an array str[0]="Thailand"; str[1]="Italy"; str[2]="spain"; str[3]="Kenya"; str[4]="Uganda"; System.out.println("\nYour strings are:"); int j=0; do{ System.out.println(str[j]); j++; }while(j<str.length); //display all entered string } }
When the above code is executed, it produces the following result
Your Strings are: Thailand Italy Spain Kenya Uganda
In this code, we are going to learn how to display character array elements in an array using do-while loop in Java language
Program 1
//Print character of an array using do whiloe loop class Disp_Array_Char_DoWhileloop{ public static void main (String args[]){ char Char[]=new char[6]; //diclaration and creation of character array Char[0]='x'; Char[1]='Y'; Char[2]='z'; Char[3]='B'; Char[4]='c'; Char[5]='F'; //initailaize index wise System.out.println("\n characters are:"); int j=0; do{ System.out.println(Char[j]); j++; }while(j<Char.length); //display all characters } }
When the above code is executed, it produces the following result
Characters are: x Y z B c F
In this code, we are going to learn how to display character array elements in an array using do-while loop in Java language
Program 2
//Print character of an array using do whiloe loop class Disp_Array_Char_DoWhileloop1{ public static void main (String args[]){ char Char[]=new char[]{'D','E','F','G','H','I'}; //diclaration and creation of character array System.out.println("\n characters are:"); int j=0; do{ System.out.println(Char[j]); j++; }while(j<Char.length); //display all characters } }
When the above code is executed, it produces the following result
Characters are: D E F G H I
Suggested for you
Do-while loop in Java language
Similar post
Java program to read and display array elements using for loop
Java program to read and display array elements using while loop
Java program to read and display array elements using Do-while loop
C code to take and display array elements using for loop
C code to take and display array elements using while loop
C code to take and display array elements using do-while loop
C++ program to read and display array elements using for loop
C++ program to read and display array elements using while loop
C++ program to read and display array elements using do-while loop
Subtract two numbers using method overriding Program 1
PHP Star triangle Pattern program Here's a simple Java program that demonstrates how to print…
Using Function or Method to Write to temperature conversion: Fahrenheit into Celsius In this article,…
Function or method of temperature conversion from Fahrenheit into Celsius In this article, we will…
Write temperature conversion program: from Fahrenheit to Celsius In this article, we will discuss the…
How to write a program to convert Fahrenheit into Celsius In this article, we will…
This website uses cookies.