• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java - Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2147483647  RSS feed

 
Elizabeth Jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following Java code provides the following error and I cannot determine why. Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2147483647. Any help would be greatly appreciated.


 
Jude Niroshan
Ranch Hand
Posts: 132
5
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Elizabeth,
Next time when you post a code, please use formating. It will make easy to read.
Your 'binNumber' variable value is exceeding the index of 'bin' array. I'm sorry. I can't figure out this mathematical approach you are trying to implement here. If you can just elaborate what you are trying to do here would be appreciated. Cos the variable names that you have given doesn't make any sense.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Elizabeth,
When posting code on the forum use code tag CodeTag .
The problem in your code in the static double Sample(double squiggle1) method ..It is returning some infinite values (return squiggle2 / squiggle1) and assigning to x at line 40.
In the line 43 the array is giving java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 2147483647 ...

Could you explain the logic behind your code ..


Thanks ,
Satya
 
Elizabeth Jones
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is supposed to simulate a Metropolis Monte Carlo sampling method by running N number of histories and obtaining the random variables squiggle1 & squiggle2. Depending on the condition, the new squiggle1 may be equal to the old squiggle2. Ultimately, the random variables in binned in the appropriate bin and the bin number is incremented up.

Apologies about the code format. I'll remember that for next time. I think it's too late to edit the code for this thread.

I am still unable to resolve the java.lang.ArrayIndexOutOfBoundsException error.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've added the code tags for you, but your indentation is inconsistent and has a mix of spaces and tabs. For posting code in any forum it is a good practice to use 2 to 4 spaces (no tabs!) per indentation level.
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Elizabeth Jones wrote:I am still unable to resolve the java.lang.ArrayIndexOutOfBoundsException error.


It looks like sqiggle1 can be zero, which causes a division by zero, which makes binNumber Infinity. See if you can correct this and re-post your post, or if you need more help, ask.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya am also agree with Knute ..

Elizabeth correct the code and give your latest update on this ..

Thanks ,
Satya
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!