Q:
Java program to access elements of character array using for each loop
belongs to collection: Java Array Programs
Java Array Programs
- Java program to find sum of array elements
- Java program to sort an array in ascending order
- Java program to sort an array in descending order
- Java program to multiply two matrices
- Java program to subtract two matrices (subtraction of two matrices)
- Java program to check sparse matrix
- Java program to find the common elements in two integer arrays
- Java program to find the common strings in two string arrays
- Java program to find missing elements in array elements
- Java program to find average of all array elements
- Java program to find differences between minimum and maximum numbers in an array
- Java program to move all zero at the end of the array
- Java program to delete a specific element from a one dimensional array
- Java program to print EVEN and ODD elements from an array
- Java program to merge two one dimensional arrays
- Java program to sort a one dimensional array in ascending order
- Java program to read and print a two dimensional array
- Program to create a two dimensional array fill it with given few characters in Java
- Java program to create a matrix and fill it with prime numbers
- Java program to print boundary elements of the matrix
- Java program to check whether a matrix is symmetric or not
- Java program to check whether a given matrix is Lower Triangular Matrix or not
- Java program to count strings and integers from an array
- Java program to remove duplicate elements from an array
- Java program to find second largest element in an array
- Java program to find second smallest element in an array
- Java program to find smallest element in an array
- Java program to count total positives, negatives and zeros from an array
- Java program to access elements of character array using for each loop
- Java program to find the length of an array
- Java program to find prime and non-prime numbers in the array
- Java program to search an item into the array using linear search
- Java program to search an item in an array using binary search
- Java program to search an item in an array using interpolation search
- Java program to sort an array in ascending order using selection sort
- Java program to sort an array in descending order using selection sort
- Java program to sort an array in ascending order using bubble sort
- Java program to sort an array in descending order using bubble sort
- Java program to sort an array in ascending order using quicksort
Program/Source Code:
The source code to access elements of the character array using "for each" loop is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created a public class Main. It contains a static method main().
The main() method is an entry point for the program. Here, we created an array of characters and initialized it with some character values. Then we accessed array elements one by one using "for each" or enhanced loop and printed them.