Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Can you pass parameters from one method into another method?

  1. #1
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    20
    Thanked 0 Times in 0 Posts

    Default Can you pass parameters from one method into another method?

    Hello everyone, I am attempting to write a program whereby it calculates the total amount of cash that the user has and also the interest. I have done that..what i now want to do is allow the user to add more money into their account. I currently have one static method which is to basically collect all the information as well as a for loop because i'm letting the user choose the rate of interest, principle value and year...what i tried to do is create a new method which just stores the number that the user chooses and then wanted to call my previous method to pass that value into it.

    For the time being i just want to know if it is possible to pass this number that is currently stored in a method into a different method. Sorry if this is unclear or for any misuse of terminology (please correct me on my terminology also XD ) Thankyou!


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Can you pass parameters from one method into another method?

    public static void methodA()
    {
        int x = 5;
        methodB(x);
    }
     
    public static void methodB(int x)
    {
        System.out.println("x = " + x);
    }

  3. The Following User Says Thank You to helloworld922 For This Useful Post:

    u-will-neva-no (April 14th, 2011)

  4. #3
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Can you pass parameters from one method into another method?

    See Passing Information To A Method.

  5. The Following User Says Thank You to dlorde For This Useful Post:

    u-will-neva-no (April 14th, 2011)

Similar Threads

  1. Help with toString method and an addObject method?
    By Camisado in forum What's Wrong With My Code?
    Replies: 2
    Last Post: February 12th, 2011, 07:00 AM
  2. 'pass by value' and 'pass by reference'
    By pokuri in forum Object Oriented Programming
    Replies: 5
    Last Post: January 26th, 2011, 11:30 AM
  3. how to pass a variable from a method to another
    By amr in forum Java Theory & Questions
    Replies: 1
    Last Post: November 20th, 2010, 10:32 PM
  4. Can't pass to the other method
    By mingming8888 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 27th, 2010, 09:44 AM
  5. Can i call init() method in destroy method.?
    By muralidhar in forum Java Servlet
    Replies: 1
    Last Post: October 22nd, 2010, 11:18 AM