lenght of string code example Example 1: length of string in java str.length(); Example 2: java length of string string.length()