String str = ""; System.out.print(str.length()); code example Example 1: length of string in java str.length(); Example 2: java length of string string.length()