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