Results 1 to 2 of 2
  1. #1
    chris.bos's Avatar
    chris.bos is offline Member
    Join Date
    Dec 2011
    Posts
    7
    Rep Power
    0

    Default Exception in thread "main" java.lang.StackOverflowError

    As the thread says i have a problem in netbeans.It says "Exception in thread "main" java.lang.StackOverflowError".
    it is printed after a recursion method run and for "x" value exp. lower than -100 and higher than +200.Anyone have any idea?
    Here is the method.
    Java Code:
    static void pyrmin(int i,int j,int x,int z)
     {           
           if (i>0)
        {
                System.out.print("a");
                i--;
        }
           else
        {
                System.out.print("b");
                j++;
        }
           if (j>z)
           {
               i=Math.abs(x)-j;
               j=1;
               z++;
               System.out.println( );        
           }
           if (z<=Math.abs(x))
               pyrmin(i,j,x,z);
     }
    Last edited by chris.bos; 12-02-2011 at 05:25 PM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,516
    Rep Power
    25

    Default Re: Exception in thread "main" java.lang.StackOverflowError

    What is printed out on the console when you execute the program?

    Add some debugging printlns to show the values of all the variables passed to the method.

Similar Threads

  1. Replies: 14
    Last Post: 04-08-2011, 06:01 PM
  2. Replies: 4
    Last Post: 02-01-2011, 08:52 AM
  3. Replies: 5
    Last Post: 06-22-2010, 03:51 PM
  4. Replies: 1
    Last Post: 11-20-2009, 07:58 PM
  5. Replies: 6
    Last Post: 07-16-2009, 03:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •