• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to find String array length

 
Mahi Ranga
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i am facing one problem i.e finding String array length.
my program is :

String str="12345678,12345679";
String arr[]=str.split(",");
when i am printing arr.length it is giving 2.but i want 8 and 8.
 
Mohamed Sanaulla
Bartender
Posts: 3166
34
Google App Engine Java Ruby
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try- arr[0].length() and arr[1].length()?

arr is an array of Strings and you want the length of the Strings and not the length of the array.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!