| | |
Java Heap Space Error
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Dec 2007
Posts: 26
Reputation:
Solved Threads: 0
Ok, i have been making a chess game program, basically what it is is a chesspiece class and a chess board class, the chessboard class has an 8x8 2-d array of chesspiece objects, then i have my frame, my frame has a parallel 2-d array of Jtoggle buttons, when a user clicks on a square a method in my chessboard class (using a location class which just stores row num and col num) returns an array of possible moves, every button on my frame uses a private method to enable and highlight all possible move spaces. However, when i run the program, i clikc on button with a pawn and nothing happens, all it does is freeze and stop running, then it says java heap error, or out of memory, and closes the current run. Plase help!
•
•
Join Date: Dec 2007
Posts: 26
Reputation:
Solved Threads: 0
ok i fixed the heap error but now im gettign an array out of bounds error -1
with this code
//down 1 and left 1
for (int r = row; row < 8; r++)
{
for (int c = column; c > -1; c--)
{
System.out.println("c " + c);
if (board[r][c] != null || board[r][c].getTeam() != board[row][column].getTeam())
{
//locations.add(new Location(r, c));
//count++;
}
if (board[r][c].getTeam() == board[row][column].getTeam() || board[r][c].getTeam() != board[row][column].getTeam())
{
c = -1;
row = 8;
}
}
}
with this code
//down 1 and left 1
for (int r = row; row < 8; r++)
{
for (int c = column; c > -1; c--)
{
System.out.println("c " + c);
if (board[r][c] != null || board[r][c].getTeam() != board[row][column].getTeam())
{
//locations.add(new Location(r, c));
//count++;
}
if (board[r][c].getTeam() == board[row][column].getTeam() || board[r][c].getTeam() != board[row][column].getTeam())
{
c = -1;
row = 8;
}
}
}
possibly or perhaps "row" is 1- prior to entering the outer loop?
for(int r = row; row<8; r++) {
for(int c = column; c>-1; c--) {
System.out.println("c "+c);
if(board[r][c]!=null||board[r][c].getTeam()!=board[row][column].getTeam()) {
//locations.add(new Location(r, c));
//count++;
}
if(board[r][c].getTeam()==board[row][column].getTeam()||board[r][c].getTeam()!=board[row][column].getTeam()) {
c = -1;
row = 8;
}
}
}•
•
Join Date: Dec 2007
Posts: 26
Reputation:
Solved Threads: 0
ok fixed that
now for this r = -2 somehow and it isnt testing it and booting it out
for (int r = row; row > -1; r--)
{
System.out.println(r);
for (int c = column; c > -1; c--)
{
if (board[r][c] != null || board[r][c].getTeam() != board[row][column].getTeam())
{
locations.add(new Location(r, c));
count++;
}
if (board[r][c].getTeam() == board[row][column].getTeam() || board[r][c].getTeam() != board[row][column].getTeam())
{
c = -1;
r = -1;
}
}
}
now for this r = -2 somehow and it isnt testing it and booting it out
for (int r = row; row > -1; r--)
{
System.out.println(r);
for (int c = column; c > -1; c--)
{
if (board[r][c] != null || board[r][c].getTeam() != board[row][column].getTeam())
{
locations.add(new Location(r, c));
count++;
}
if (board[r][c].getTeam() == board[row][column].getTeam() || board[r][c].getTeam() != board[row][column].getTeam())
{
c = -1;
r = -1;
}
}
}
Last edited by slayer10; Feb 28th, 2008 at 8:32 pm.
![]() |
Similar Threads
- IE shuts down and leaves message on desktop (Viruses, Spyware and other Nasties)
- problem in gentoo (Kernels and Modules)
- problem in java (Java)
- OutOfMemory Error (Java)
- Unexplainable Error Help Needed! (Windows NT / 2000 / XP)
- Exception error (HTML and CSS)
- IE Browser shutting down and shows error on desktop (Java)
- Error Message in the VM (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: Splitting double into its integer portion and decimal portion
- Next Thread: Removing a specific item from a linked list
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth busy_handler(null) chat class classes client code columns component constructor database designadrawingapplicationusingjavajslider draw eclipse editor error errors event eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress input integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia link linux list loop map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle parsing plazmic print problem program programming project recursion scanner screen server set sharepoint size smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads time tree unlimited utility webservices windows






