william007
asked on
Level of stack allowed by java
Does java specify how many level of stack is allowed? or it is machine dependent?
I try this function, it only allows me up to n=6955, n=6966 will cause stack overflow.
public static double fact(double n){
if(n==0) return 1;
}
I try this function, it only allows me up to n=6955, n=6966 will cause stack overflow.
public static double fact(double n){
if(n==0) return 1;
}
ASKER
Exactly Venabili, thanks for catching that:)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
And of course the last one had to read "the stack size" and not the "stack trace"...
:) Sorry about this
:) Sorry about this
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The stack and the heap are separate, and there's nothing an explicit call to run the garbage collector will do that the VM wouldn't have done on its own when space got tight.
I stand corrected.
ASKER
Thanks:)
public static double fact(double n){
if(n==0) return 1;
return fact(n-1)*n;
}
or you mean another function. Because what you posted won't even compile :)