length method vs length() method in Java.(Different Type to use length & length() in String & Array in JAVA)
CODING:
class length
{
public static void main(String[] args)
{
int i;
String[] a = { "Programming", "Example", "Of","JAVA" };
for(i=0;i<a.length;i++){
System.out.println("Index[" + i +"]=" + a[i]);
}
System.out.println("The size of the array is " + a.length);
for(i=0;i<a.length;i++){
System.out.println(a[i] + " length is "+ a[i].length());
}
String s = "Programming Example Of JAVA";
System.out.println(s);
System.out.println("The size of the String is " + s.length());
}
}
class length
{
public static void main(String[] args)
{
int i;
String[] a = { "Programming", "Example", "Of","JAVA" };
for(i=0;i<a.length;i++){
System.out.println("Index[" + i +"]=" + a[i]);
}
System.out.println("The size of the array is " + a.length);
for(i=0;i<a.length;i++){
System.out.println(a[i] + " length is "+ a[i].length());
}
String s = "Programming Example Of JAVA";
System.out.println(s);
System.out.println("The size of the String is " + s.length());
}
}
Comments
Post a Comment