String Length Java

To find the String Length, the String class comes with length() method returning the number of characters as an int. Following program on String Length illustrates. public class Demo { public static void main(String args[]) { String str1 = “hello”; String str2 = “”; int x = str1.length(); System.out.println(x); System.out.println(“hello length: ” + str1.length()); System.out.println(“Empty …

String Length Java Read More »