/*
Java String Length Example
This example shows how to get a length of a given String object.
*/
public class StringLengthExample {
public static void main(String[] args) {
//declare the String object
String str = "Hello World";
//length() method of String returns the length of a String.
int length = str.length();
System.out.println("Length of a String is : " + length);
}
}
/*
Output of a program would be:
Length of a String is : 11
*/
Bookmark/Search this post with:
hi !!
hi i m new to java!!
and one of our tasks to create a program to count the number of words in a string and the number of Characters in that string..
can any one let me kw where i mistaken??
i hv create the prog but it takes a dot as a chacater what to do??
Post new comment