//JAVA Program to check length of a String.
public class StringLength
{
public static void main(String args[])
{
String str; //declaring string str
str = "Abhishek";
//We will use length() method here.
//now let us declare a int
int len;
len = str.length(); //length() is a method in String class which gives the length of a string
System.out.println("Length of a String is: " +len);
}
}
Output:
Length of a String is: 8
Good content
ReplyDelete