how to know the length of string in java code example Example: length of string in java str.length();