Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6339491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:39:32+00:00 2026-05-24T19:39:32+00:00

So thanks to @fireshadow52, I’ve managed to come up with this script that sin

  • 0

So thanks to @fireshadow52, I’ve managed to come up with this script that sins args[0]. However, it spits out a StackOverFlow error. What is this, and how (if possible) would you spot them?

class SIN {
    public static void main(String[] args) {
        double result = sin(args[0]);
    }
    public double sin(x) { Math.sin(x); return sin(x); }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:39:32+00:00Added an answer on May 24, 2026 at 7:39 pm

    An excerpt from an answer to a similar question…

    Parameters and local variables are allocated on the stack (with reference types the object lives on the heap and a variable references that object). The stack typically lives at the upper end of your address space and as it is used up it heads towards the bottom of the address space (ie towards zero).

    Your process also has a heap, which lives at the bottom end of your process. As you allocate memory this heap can grow towards the upper end of your address space. As you can see, there is the potential for the heap to "collide" with the stack (a bit like techtonic plates!!!).

    A Stack Overflow error means that the stack (your method) overflowed (executed itself so many times that it crashed). Stack Overflow errors usually result from a bad recursive call.

    In general, if your method name doesn’t have the keyword void in it, make sure the return value isn’t the same as the method name. Otherwise, the stack will overflow, crashing your program. Just replace these lines:

    Math.sin(x);
    return sin(x);
    

    …with this line…

    return Math.sin(x);
    

    …and you should be good to go!

    Sometimes in can be a bit tricky to find out when a program will crash:

    Q: Will this program crash? If so, why?

    public void MultiplyByNintyNine(byte num) {
        MultiplyByNintyNine(num * 99);
    }
    

    A: Actually, this could crash for two reasons:

    1. The number could get so large that the JVM can’t handle it.

    2. The function could call itself so many times that the JVM crashes (i.e. a Stack Overflow error).

    The latter case is the more reasonable; even though the method doesn’t actually return anything, the method is still called.

    In some cases, it is perfectly OK to return the method name. Just make sure you have a terminating condition if you do, though! Here is an example similar to yours (that doesn’t crash):

    import java.io.*;
    //class declaration here
    
    public static void main(String[] args) {
        System.out.println(guessTheNumber());
    }
    
    public String guessTheNumber() {
        int guess;
        System.out.print("Guess the number:_");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            guess = Integer.parseInt(br.readLine());
        } catch (NumberFormatException e) {
            System.err.println("You didn't guess a number.");
            guessTheNumber();
        } catch (IOException e) {
            System.err.println("An unexpected error occured. Please try again.");
            guessTheNumber();
        }
        if (guess == 4) {
            return "YAY! You get a prize!";
        } else {
            System.err.println("WAAHH! You get to guess again!");
            guessTheNumber();
        }
    }
    

    Warning: The only way to stop this code (from the code itself) is to enter 4.

    In the above case, the terminating condition occurs when a user enters an actual number and that number is 4.


    P.S. If you’re feeling down, here is a REAL StackOverFlow error!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks to a Q&A on stackoverflow. I just found out how to determine the
Thanks to stackoverflow i finally understood that i need to compile from the source
Thanks to this board I have managed to retrieve the name and the price
thanks to help from stackoverflow posters I have set up some oop javascript. However,
Thanks for reading this. I am dynamically generating some data which includes a select
Thanks for a solution in C , now I would like to achieve this
Thanks to a library upgrade (easymock 2.2 -> 2.4), we're having tests that have
Thanks for reading this. I have markup similar to what is below. Using the
Thanks for reading this I thought I could use find(), but couldn't make it
thanks for reading! Here's what I'm up to. I'm writing a WordPress plugin that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.