Originally posted by Campbell Ritchie:
Mark Weber is right about the ArrayList.
I don't think h = i actually sorts out your problem. Using i when number.equals("STOP") still gives you an out-by-one error. Hence the Exception.
hmm,...
okay, lets go through this then:
lets take an array of 5 elements as example....
( e.g.:
String[] elements = new String[5]; )
then we begin with the entries.....
1st entry: x1 -> position in Array : "0"
2nd entry: x2 -> position in Array : "1"
3rd entry: "STOP" -> position in Array: "2"
now this is done:
h = i; ....
then: String[] elementsCorrected = new String[h];
then we do:
elementsCorrected[j] = elements[j]
"elements" is now an Array with (h = 2) elements...
---> (for 0 <= J < h ) !!! in any case it did work for me....however: only when i did this afterwards:
elements = elementsCorrected; break; (and voila! NO NullPointer or number excepions

)
as against:
return elementsCorrected;...as commented in my earlier post (still dont know why though :/ )
but it worked *lol*
[ June 01, 2006: Message edited by: Wolfgang Obi ]