Menu
Question Index
...

Write a program to calculate the length of the given input character array by using length method.

Input (char[]) Output (int)
{'M', 'E', 'R', 'I', 'T', 'C', 'A', 'M', 'P', 'U', 'S'} 11
{'H', 'Y', 'D', 'E', 'R', 'A', 'B', 'A', 'D'} 9
{'V', 'i', 'j', 'a', 'y', 'a', 'w', 'a', 'd', 'a'} 10
{'H', 'I', 'H', 'E', 'L', 'L', 'O'} 7
{'Y', 'O', 'U', 'R', 'J', 'A', 'V', 'A', 'S', 'C', 'H', 'O', 'O', 'L'} 14



class CalculateLengthOfString
{
    public static void main(String s[])
    {
        char input[] = {
        'M',
        'E',
        'R',
        'I',
        'T',
        'C',
        'A',
        'M',
        'P',
        'U',
        'S'};
        System.out.println("Length of the array is : " + getLengthOfCharacterArray(input));

    }


    public static int getLengthOfCharacterArray(char[] input) {
    }

}

Doubts

Problems

Topic: Java length() Method | length() Method In Java - Strings

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App