Results 1 to 9 of 9
Thread: Re: Help with arrays
- 03-12-2012, 04:08 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
Re: Help with arrays
I also have a problem. I found an example of static recursion with the passing of parameters but I as wondering if it was the right set up. I want to write a static recursive method for summations then run it with a program that can show the values of the parameters on each call and then the returned value on each call
Java Code:public class A { public static int staticMethod(int param){ int a=10; int b=b+a; int c=(param+b)/param; return c; } }Last edited by Norm; 03-12-2012 at 04:12 PM. Reason: MOVED to own thread & added code tags
- 03-12-2012, 04:16 PM #2
Re: Help with arrays
The posted code is not recursive. Can you explain what you expect this code to do?
What is the purpose of the variables: a & b? They will always have the same value: 10
- 03-12-2012, 04:16 PM #3
Senior Member
- Join Date
- Mar 2011
- Posts
- 171
- Rep Power
- 0
Re: Help with arrays
that's not a recursive method. Try and fix it up a bit, you're return statement needs to be different
- 03-12-2012, 04:23 PM #4
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
Re: Help with arrays
So basically I want the outcome to show the values of the parameters on each call and then the returned value on each call. Sorry I'm not good at this stuff. The example is not my actual set-up. I just want a proper way to set up the code and compile it
- 03-12-2012, 04:28 PM #5
Re: Help with arrays
What do you mean by the "outcome"?
The method only has one parameter. By 'show' do you mean print its value on the console?show the values of the parameters on each call
Your explanation of what you want to do is still not clear
In pseudo code:
print the parameters
call the method with the parameters
print the value returned by the method
- 03-12-2012, 04:53 PM #6
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
Re: Help with arrays
Yea. That's what im looking 4.
- 03-12-2012, 04:57 PM #7
Re: Help with arrays
Is the problem solved now?
- 03-12-2012, 05:10 PM #8
Member
- Join Date
- Mar 2012
- Posts
- 10
- Rep Power
- 0
Re: Help with arrays
Sorry to put you through all the trouble. i just don;t know how to write a code for the problem. I'll reply if i find an answer. thanks for your help
- 03-12-2012, 08:20 PM #9
Similar Threads
-
Casting Enum Type arrays to object type arrays
By nmvictor in forum Advanced JavaReplies: 4Last Post: 02-17-2012, 12:49 PM -
arrays and multidimensional arrays
By belfast09 in forum New To JavaReplies: 5Last Post: 06-14-2011, 01:28 PM -
Help with arrays!
By corrax in forum New To JavaReplies: 8Last Post: 04-06-2011, 07:36 AM -
store array of arrays in array of arrays
By joost_m in forum New To JavaReplies: 4Last Post: 04-19-2010, 10:32 AM -
Arrays.sort... why sorting all arrays in class?
By innspiron in forum New To JavaReplies: 6Last Post: 03-23-2010, 01:40 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks