This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • 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
Saloon Keeper
Posts: 3159
33
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