Vinay D. answered 04/14/16
Tutor
4.8
(12)
Software Engineer with over 13 years of experience in programming.
The below method is one of the solutions to your question -
Assuming your array is of the String[] type.
/**
* @param index - the index in the array
* @param array - the array
* @return the length of element at index of array.
*/
public static int getLengthOfElementInArray(int index, String[] array){
return array[index].length();
}
* @param index - the index in the array
* @param array - the array
* @return the length of element at index of array.
*/
public static int getLengthOfElementInArray(int index, String[] array){
return array[index].length();
}
Note that this is the basic code and it does not handles any exceptions. For example, if the array that you are passing is null or if index that you are passing is greater than the length of array, it will give exceptions.
Oshin B.
04/16/16