"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
prathi suku wrote:Thanks for the solution. Acually the array length is not causing the problem .
The problem I am facing is this:
I have a String array arr[], which has values like {"a","b","c"} or {"","",""}
The array length value remains the same
I am using the String split method on the array like arr.split("\"").
So in the first case,arr[] values get stored like
arr[0]=a
arr[1]=,
arr[2]=b
arr[3]=,
arr[4]=c
I am taking the last value in the array and assigning it to a variable.For example the value "c" which is arr[4] needs to be assigned to a variable.This is working fine.
When trying to do the same for the second case where the strings are empty "",I get arrayindexout of bound exception. arr[4] does not seem to exist in this case.
I am checking a condition
if (arr[4].equals("") || arr[4]==null)
but it throws the arrayindexoutof bound exception before reaching here,telling that arr[4] does not exist.
Please advise.
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |