//write a program to calculate length of String?
package govindtest;
package govindtest;
public class LengthCalculate {
public static int calculateLegth(String s1)
{
int c=0;
char[] ch = s1.toCharArray();
for(int i=0;i<ch.length;i++)
{
c++;
}
return c;
}
public static void main(String[] args) {
int x= LengthCalculate.calculateLegth("Govind Ballabh Khan");
int x= LengthCalculate.calculateLegth("Govind Ballabh Khan");
System.out.println("length of String="+x);
}
}
}
No comments:
Post a Comment