Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 01-24-2005, 11:58 AM   #1 (permalink)
Crazy
 
[JAVA] StringIndexOutOfBoundsException

I'm still pretty new to Java. Right now i'm working on a POS program. Eclipse threw this error at me.

Code:
java.lang.StringIndexOutOfBoundsException: String index out of range: 34
ProductCatalog[productSpecifications = null]
-Rick
BoltedDown is offline  
Old 01-24-2005, 03:37 PM   #2 (permalink)
a-j
Tilted
 
I'm not sure what you want. Are you wondering what the error means? Where in your program caused the error? How to fix the problem?

Please be less vague.
a-j is offline  
Old 01-24-2005, 05:07 PM   #3 (permalink)
Crazy
 
Location: The state of denial
Agreed, at least show a code snippet around the line number the exception is being thrown on, then we can be much more helpful.
__________________
Smoke me a kipper, I'll be back for breakfast.
madcow is offline  
Old 01-24-2005, 10:03 PM   #4 (permalink)
Psycho
 
noodles's Avatar
 
Location: sc
ummm...yeah. code.
are you trying to use a string function on an index that doesn't exist?
/me got nothin
__________________
This is what is hardest: to close the open hand because one loves.
Nietzsche
noodles is offline  
Old 01-25-2005, 01:07 PM   #5 (permalink)
Insane
 
AngelicVampire's Avatar
 
How long is the string? Strings can be created as an array, if you are trying to work beyond the end of it then you will create errors iirc.
AngelicVampire is offline  
Old 01-27-2005, 07:56 PM   #6 (permalink)
Crazy
 
Location: San Diego, CA
You're accessing character 34 of a string with length less than 35 (Java arrays are 0-based). That's what the error is telling you. Without code I can't help you any more than that.
__________________
"Don't believe everything you read on the internet. Except this. Well, including this, I suppose." -- Douglas Adams
Rangsk is offline  
Old 02-06-2005, 08:55 AM   #7 (permalink)
Addict
 
Location: M[ass]achusetts
ProductCatalog[productSpecifications = null] <-- that is your code right?
if so, why are you setting productSpecifications to null in the indexer?

otherwise, outofbounds usually means something like this...

string[] mystringarray = new string[3]

^^ that array will have 4 valid objects...
mystringarray[0]
mystringarray[1]
mystringarray[2]
mystringarray[3]

but if you do mystringarray[4], that's out of bounds. so you just have to make sure that the variable you use to retrieve an index of an array is within the bounds of the array.

to see how big an array is use the 'length' variable
Code:
int length = mystringarray.length
__________________
In the end we are but wisps
ManWithAPlan is offline  
Old 02-08-2005, 10:29 PM   #8 (permalink)
Upright
 
It's out of bounds because it's null, don't focus on the exception, focus on why that object is null.
skitz0 is offline  
 

Tags
java


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 07:05 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62