Beginner programming- strange problem
Sorry if this is blatently obvious but i am new to programming.
My problem is with this piece of code:
currEx = in.charAt(currSubStr);
Java says the following:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
I assume this means that the int currSubString is not valid, however i know foor sure that this is 0 seeing as i assign that value one line before the one i am having a problem with.
Any help would be greatly appreciated, as i am stumped!
Re: Beginner programming- strange problem
Are you validating the length of the String before you use charAt()? Maybe the String is not as long as you think it is. If a String's length is 0, it has *no* valid indexes.