In this tutorial, we will discuss the concept of Print Character array elements in Java
In this topic, we are going to learn how to print character array elements in Java programming language using loops.
In this blog, We have already discuss that “What is an array“, type of arrays and how to access it(one dim, two dim and three dim arrays)
Arrays are the special type of variables to store Multiple type of values(int, string,char, etc)under the same name in the continuous memory location. we can be easily accessed using the indices(indexes)
In this program, we are briefing print character elements of an array using for loop in Java language
Program 1
//Print character of an array using for looop class Disp_Array_Char_For1{ public static void main (String args[]){ char Char[]=new char[6]; //declaration and creation of character array Char[0]='A'; Char[1]='B'; Char[2]='C'; Char[3]='D'; Char[4]='E'; Char[5]='F'; System.out.println("\n characters are:"); for(int j=0; j<Char.length; j++){ System.out.println(Char[j]); }//display all entered characters } }
When the above code is executed, it produces the following result
characters are: A B C D E F
In this program, we are briefing print character elements of an array using while loop in Java language
Program 2
//Print character of an array using whiloe loop class Disp_Array_Char_While1{ public static void main (String args[]){ char Char[]=new char[6]; //diclaration and creation of character array Char[0]='a'; Char[1]='b'; Char[2]='c'; Char[3]='d'; Char[4]='e'; Char[5]='f'; System.out.println("\n characters are:"); int j=0; while(j<Char.length){ System.out.println(Char[j]); j++; }//display all entered characters } }
When the above code is executed, it produces the following result
characters are: a b c d e f
In this program, we are briefing print character elements of an array using do- while loop in Java language
Program 3
//Print character of an array using whiloe loop class Disp_Array_Char_DoWhile1{ 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'; System.out.println("\n characters are:"); int j=0; do{ System.out.println(Char[j]); j++; }while(j<Char.length); //display all entered characters } }
When the above code is executed, it produces the following result
characters are: x y z b c f
Suggested for you
for loop in Java
while loop in Java
Data type and variable in Java
Operator in Java
Similar post
Code to read and print integers of an array in Java
Code to read and print strings of an array in Java
Code to read and print characters of an array in Java
Code to read and print integers of an array in C++
Code to read and print strings of an array in C++
Code to read and print characters of an array in C++
Code to read and print integers of an array in C
Code to read and print strings of an array in C
C# inverted full pyramid star pattern In this article, we will discuss the concept of…
C# Full Pyramid star pattern program In this article, we will discuss the concept of…
Program to count vowels, consonants, words, characters and space in Java In this article, we…
How to print multiplication table using Array in C++ language In this post, we will…
C Program to multiplication table using Array In this tutorial , we will discuss about…
Java program to check odd or even using recursion In this tutorial, we discuss a…