String Length in java:
The length of the String is the actual number of character that contains in it.To get this value,call the length() method as shown below:
int length();
Here is a short program to demonstrate String length:
package stringdemo;
public class StringLengthDemo {
public static void main(String[] args) {
char ch[]={'a','e','i','o','u'};
String s= new String(ch);
System.out.println(s.length());
}
}
The output of this program is as below:
5
0 comments:
Post a Comment