Sunday, January 26, 2014

How to determine the length of a string?

Source:
public class StringLength {
   public static void main(String[] args) {
      String str = "abcdefghijflmnopqrstuvwxyz";
      System.out.println(str);
      System.out.println("length: " + str.length());
   }
}

Output:
   $ java StringLength 
   abcdefghijflmnopqrstuvwxyz
   length: 26

Blog Archive