any other way to find char array length?

Posted by user2785137 on Stack Overflow See other posts from Stack Overflow or by user2785137
Published on 2013-11-01T03:46:13Z Indexed on 2013/11/01 3:53 UTC
Read the original article Hit count: 72

Filed under:
public static int getLenth(char[] t)
{
    int i=0;
    int count=0;
    try
    {
        while(t[i]!='\0')
        {

            ++count;
            i++;
        }
        return count;
    }
    catch(ArrayIndexOutOfBoundsException aiobe)
    {
        return count;
    }
}

This method returns length of charArray. But my question is, is there is some other "ways" to find the length of charArray without using this try, catch statements & all ??

Thanks in advance :)

© Stack Overflow or respective owner

Related posts about java