Results 1 to 9 of 9
  1. #1
    gable.able is offline Member
    Join Date
    Mar 2012
    Posts
    10
    Rep Power
    0

    Default 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 05:12 PM. Reason: MOVED to own thread & added code tags

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default 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

  3. #3
    adjit is offline Senior Member
    Join Date
    Mar 2011
    Posts
    171
    Rep Power
    0

    Default 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

  4. #4
    gable.able is offline Member
    Join Date
    Mar 2012
    Posts
    10
    Rep Power
    0

    Default 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

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Help with arrays

    What do you mean by the "outcome"?
    show the values of the parameters on each call
    The method only has one parameter. By 'show' do you mean print its value on the console?
    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

  6. #6
    gable.able is offline Member
    Join Date
    Mar 2012
    Posts
    10
    Rep Power
    0

    Default Re: Help with arrays

    Yea. That's what im looking 4.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default Re: Help with arrays

    Is the problem solved now?

  8. #8
    gable.able is offline Member
    Join Date
    Mar 2012
    Posts
    10
    Rep Power
    0

    Default 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

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: Help with arrays

    Quote Originally Posted by gable.able View Post
    Yea. That's what im looking 4.
    Please use proper words, not '4' for 'for'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Casting Enum Type arrays to object type arrays
    By nmvictor in forum Advanced Java
    Replies: 4
    Last Post: 02-17-2012, 01:49 PM
  2. arrays and multidimensional arrays
    By belfast09 in forum New To Java
    Replies: 5
    Last Post: 06-14-2011, 02:28 PM
  3. Help with arrays!
    By corrax in forum New To Java
    Replies: 8
    Last Post: 04-06-2011, 08:36 AM
  4. store array of arrays in array of arrays
    By joost_m in forum New To Java
    Replies: 4
    Last Post: 04-19-2010, 11:32 AM
  5. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 02:40 AM

Posting Permissions

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