Hi Parveen,

I think there is no other method available in String class to find the Length. There is some way to find the length by converting the Strings available in String class to char or byte method types. You can get this idea from the following code. But its extra work for compiler rather than using String lenght method

|*import *java.io.*;

*class *StringLength{
*public static **void *main(String[] args){
*try*{
BufferedReader object=*new *BufferedReader (*new *InputStreamReader(System.in));
System.out.println("Eneter string value:");
String s=object.readLine();
||*char[] *||chrCharGroup = s.toCharArray();||
*int *len=||||chrCharGroup||.length();
System.out.println(len);
}
*catch*(Exception e){}
}
}|





On 01/23/2011 12:29 AM, Parveen Thakur wrote:
Hi all,

How we can check the length of string without use of Lenght() menthod

|*import *java.io.*;

*class *StringLength{
*public static **void *main(String[] args){
*try*{
BufferedReader object=*new *BufferedReader (*new *InputStreamReader(System.in));
System.out.println("Eneter string value:");
String s=object.readLine();
*int *len=s.length();
System.out.println(len);
}
*catch*(Exception e){}
}
}|

--
Best Regards And Thanks :
Parveen Thakur,
Contact no.-9988208440.
--
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com To unsubscribe from this group, send email to javaprogrammingwithpassion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en

--
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to