How To Fix The Stack Overflow Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
Stack Overflow Error Java Recursion
company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions how to fix stack overflow error java Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million how to resolve stack overflow error in java programmers, just like you, helping each other. Join them; it only takes a minute: Sign up How do I fix this stack overflow error? up vote 2 down vote favorite 1 So I have what I
Java.lang.stackoverflowerror Java
think is pretty good code for a sudoku solver in java but I need some help with this method. It gives me a stack overflow when I embed it in a main method. The problem is that my method doesn't know how to turn around and fix its mistakes. I need a boolean flag (one that, unlike the one used in the code below, actually works preferably) or something to let it know when
Java.lang.stackoverflowerror Android
it should turn back and when it can again go forwards and continue solving the game. Thanks for any help you can give public void play(int r, int c){//this method throws the StackOverflowError if(needAtLoc(r,c).size()==9){ int num=1+generator.nextInt(9); setCell(r,c,num,this); if(c<8){ System.out.println(this);/////////////// play(r, c+1); } else{ play(r+1, 0); } } else{ if(needAtLoc(r,c).size()==0){//no possible moves THIS IS THE PROBLEM LINE!!! if(c>0){ play(r, c-1);//play last cell, in column to left } else{ if(r==0){ play(r,c);//first square, so must play again (can't go back) } else{ play(r-1, 8);/*first cell of row so must go to previous row and the end column*/ } } } else{//if there are possible moves int num=needAtLoc(r,c).remove(generator.nextInt(needAtLoc(r,c).size())); setCell(r,c,num,this);//set the value of the cell System.out.println(this);////////////// if(r==8 && c==8){//the end of the cell has been reached so must end recursive call return; } else{ if(c<8){ play(r, c+1);//normal, next cell } else{ play(r+1, 0);/*last cell in row so we go to next one in the first column ("return" button)*/ } } } } } java recursion stack-overflow sudoku share|improve this question edited Jan 7 '10 at 5:23 community wiki 8 revs, 7 users 37%user233542 1 you should tell people it's Java. That's a lot of code, by the way, think about breaking it down to functions. Are you sure solving a sudoku fits on the stack? –Kobi Dec 17 '09 at 6:14
and DropEventsExpandableListViewGridViewHorizontalScrollViewImageButtonImageViewLinearLayoutListViewNotificationsPasswordProgressBarProgressDialogRadioButtonRadioGroupRatingBarRelativeLayoutScrollViewSelectorSettingsSpinnerSurfaceViewTextBoxTimePickerToastToggleButtonWebViewviewMenuOnClickListenerViewPagerwidgetAutoCompleteTextViewEditTextFrameLayoutSeekBarSlidingDrawerStackViewTextViewViewFlipperxmlgamescanvasmain loopOpenGL ESCore JavaanimationapacheANTcommonsbeanutilsconvertersArrayConvertercliBasicParsercodecbinaryBase64Base64OutputStreamcsvdbcpBasicDatasourcePoolingConnectioniocomparatorCompositeFileComparatorDirectoryFileComparatorLastModifiedFileComparatorNameFileComparatorPathFileComparatorFilenameUtilsFileUtilsIOUtilsmonitorFileAlterationMonitorlang3CharUtilsClassPathUtilsmathFractionNumberUtilsStringUtilsloggingLogfactorynetCookieStoreFTPClientURLClassLoaderURLConnectionluceneappletaspectjbeanscajoCharacterclassComperablecryptoDesign PatternsdecoratorstrategyGenericsGradlegsonGsonBuilderstreamJsonReaderJsonWriterioBufferedInputStreamBufferedOutputStreamBufferedReaderBufferedWriterByteArrayInputStreamByteArrayOutputStreamConsoleDataInputStreamDataOutputStreamExternalizableFileFileDescriptorFileInputStreamFilenameFilterFileOutputStreamFileReaderFileWriterInputStreamInputStreamReaderIOExceptionObjectInputStreamObjectOutputStreamOutputStreamPrintWriterRa
Method https://developer.ibm.com/answers/questions/243505/getting-javalangstackoverflowerror-how-to-resolve.html java.lang Class StackOverflowError java.lang.Object java.lang.Throwable java.lang.Error java.lang.VirtualMachineError java.lang.StackOverflowError All Implemented how to Interfaces: Serializable public class StackOverflowError extends VirtualMachineError Thrown when a stack overflow occurs because an application recurses too deeply. Since: JDK1.0 stack overflow error See Also:Serialized Form Constructor Summary Constructors Constructor and Description StackOverflowError() Constructs a StackOverflowError with no detail message. StackOverflowError(Strings) Constructs a StackOverflowError with the specified detail message. Method Summary Methods inherited from classjava.lang.Throwable addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace,