cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
881
Views
0
Helpful
1
Replies

Getting lenght of String array

Muhammad Usman
Level 1
Level 1

Hi,

How can i find the lenght of a string array, i have used length method to calculate length of single string value,e.g

String value = "test"

int length = value.length()

Now i want to calculate length of a string array.e.g

String csv_values = "test,by,random"

String[] str = csv_values.split(",")

int lenght = str.length()

As you can see i want to calculate total number of entries in an array after i split it dynamically.

Currently it is giving me exception, "Unable to parse exception; Undefined method: length for class: [Ljava.lang.String]"

Thanks

1 Accepted Solution

Accepted Solutions

Anthony Holloway
Cisco Employee
Cisco Employee

This is a tricky one.  An Array has a length property, unlike a String which has a length method.

So...

int length = str.length

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

View solution in original post

1 Reply 1

Anthony Holloway
Cisco Employee
Cisco Employee

This is a tricky one.  An Array has a length property, unlike a String which has a length method.

So...

int length = str.length

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.