Java-Character Array

Character Array

The character array is a data structure that stores a collection of character values of the char type. The character array is equivalent to the integer array. The character representation consists of a list of the array’s elements, enclosed in braces (“{}”). Adjacent elements are separated by the characters ‘,’.

Program

Program Source

import java.util.Arrays;

public class Javaapp {
 
    public static void main(String[] args) {
     
        char[] letters = {'A','B','C','D','E','F'};
     
        System.out.println("letters[0] = "+letters[0]);
        System.out.println("letters[2] = "+letters[0]);
        System.out.println("letters[5] = "+letters[0]);
        System.out.println("letters    = "+Arrays.toString(letters));
    }
}

Leave a Comment