05.0 Java Notes‎ > ‎Java: String‎ > ‎

Java String: length()

determines the length of a string


    public void lenghtExample1()
    {
        String str;
        int len;
        
        str = "Student, Joe";

        // find the length of a string
        len = str.length();

        // output the length of the string
        System.out.println("The string " + str + " is " + len + " characters long.");        
    }


Comments