Results 1 to 4 of 4
  1. #1
    dexterc is offline Member
    Join Date
    Nov 2011
    Location
    San Jose, CA
    Posts
    4
    Rep Power
    0

    Default Passing method results to each other

    Hi, I am try write a program that does something as follows

    Main()
    {
    int number1 = method1()
    anArray = method2()
    method3(anArray, number1)
    }
    method1()
    {
    returns an int
    }
    method2()
    {
    returns an array
    }
    method3(anArray, number1)
    {
    Takes anArray and number1 and manipulates it and returns the manipulation to the main.
    }


    The problem is I can't get the 3rd method to read the variables from the main, how do I pass them to it?

    Thanks,
    Dexter

  2. #2
    CHLim is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

    Default Re: Passing method results to each other

    Simple, you just declare those particular methods outside of the main method but within the class (ie as a instance variable.)

  3. #3
    dexterc is offline Member
    Join Date
    Nov 2011
    Location
    San Jose, CA
    Posts
    4
    Rep Power
    0

    Default Re: Passing method results to each other

    Thank you very much! I'm new to functions but man they are useful.

  4. #4
    CHLim is offline Member
    Join Date
    Nov 2011
    Posts
    24
    Rep Power
    0

Similar Threads

  1. Correctly passing an element to a method
    By aianta in forum New To Java
    Replies: 5
    Last Post: 10-28-2011, 08:52 PM
  2. Passing method as argument
    By susieferrari in forum New To Java
    Replies: 26
    Last Post: 06-13-2011, 11:43 AM
  3. passing percent to public int method
    By BillyB in forum New To Java
    Replies: 3
    Last Post: 02-04-2011, 07:08 AM
  4. Passing an array to a method.
    By twcast in forum New To Java
    Replies: 9
    Last Post: 02-10-2010, 10:13 AM
  5. Passing Class Reference to method
    By nekt in forum Advanced Java
    Replies: 5
    Last Post: 03-26-2009, 06:08 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
  •