LengthOf - show length of things : String « Data Type « Java






LengthOf - show length of things

     
/**
 * LengthOf - show length of things
 */
public class LengthOf {
  public static void main(String[] argv) {
    int    ints[] = new int[3];
    Object objs[] = new Object[7];

    String stra = "Hello World";
    String strb = new String();

    // Length of any array - use its length attribute
    System.out.println("Length of argv is " + argv.length);
    System.out.println("Length of ints is " + ints.length);
    System.out.println("Length of objs is " + objs.length);

    // Length of any string - call its length() method.
    System.out.println("Length of stra is " + stra.length());
    System.out.println("Length of strb is " + strb.length());
  }
}



           
         
    
    
    
    
  








Related examples in the same category

1.Get String hash code
2.To extract Ascii codes from a String
3.Show string escapesShow string escapes
4.Convert string to char array
5.See if Strings are shared in Java
6.Find text between two strings
7.If a string is empty or not
8.Count word occurrences in a string
9.Check for an empty string
10.Remove leading and trailing space from String
11.Reverse a string
12.Put quotes around the given String if necessary.
13.Starts With Ignore Case
14.Repeat String
15.implements CharSequence