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 8466435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:20:33+00:00 2026-06-10T15:20:33+00:00

Hello android/Java developers, When a function call a function and that function call another

  • 0

Hello android/Java developers,

When a function call a function and that function call another one and so on, how many calls (stack length) would get me into stack over flow? Is there a general rule of thumb?

The reason i am asking is because I am now which is more efficient(design wise) for my 5 players cards game

Solution 1:

for(int i=0;i<100;i++){
         p1.play();
         p2.play();
         p3.play();
         p4.play();
}

Solution 2:

   p1.play();    //where p1.play() calls p2.play() and so on until p4 calls p1 again.   
                 // this will go on for 100 times

I prefer solution 2 so if there is a crash I can see all the function calls from p1 at i=0 till p4 at i=100

but with solution 1, the stack is much shorter but when there is a crash I will see on the beginning of the loops a the called function play() where crash happened

What do you suggest? I know it is kinda 2 questions in 1 but they are very related

Thank you all

  • 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-06-10T15:20:35+00:00Added an answer on June 10, 2026 at 3:20 pm

    In my experience, a stack overflow in Java is almost always due to a programming error. See typical sizes here.

    Now, your second solution is, IMO, quite ugly… almost a programming error. Assuming N=100 is (sort of) the duration of your game, it sounds just wrong that the memory consumption (stack size) increases with it. I don’t like that solution at all.

    when there is a crash I will see on the beginning of the loops a the
    called function play() where crash happened

    I don’t see the real advantage. Why not put a try catch block so that in case of a crash you can print out the iteration number?

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

Sidebar

Related Questions

Hello android developers, I was struggling to get this work but failed and now
When I tried to do a simple modification of the hello android program that
Hello i am new in android and i am developing one application in which
Hello i'm a new coder to android. I have a program that Plays Pauses
Hello Android developers, I've got a problem with the Android SearchView widget. What I'm
Hello I would like to make my layout clickable I set android: clickable =
Hello fellow developers :) I've made a very basic image fetcher for Android to
Hello android designers, 1-I have been wondering. Is it a good design approach to
Hello Android programmers, I am working on parsing a website in my application. This
Hello Android programmers, I am making a currency application and to do this, I

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.