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: Passing a parameter of current object

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Passing a parameter of current object

    I have the following problem. I have two classes named apple and orange. In orange I have a function:

    functionX(Apple p){
    }

    public Apple() {
     
    functionX(????);
     
    }

    I'm wanting to know what goes in the question marks. I want to pass the current apple to functionX which is in the orange class. Help please


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Passing a parameter of current object

    The this variable is a reference to the current object.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Feb 2013
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Passing a parameter of current object

    Quote Originally Posted by Norm View Post
    The this variable is a reference to the current object.
    Ah. I was doing that but just realized the problem lies with my second parameter

Similar Threads

  1. Passing as a parameter, an object + another variable
    By goochasauras in forum What's Wrong With My Code?
    Replies: 6
    Last Post: December 11th, 2012, 11:13 PM
  2. Iterate over array, changing current object?
    By slimchance in forum Loops & Control Statements
    Replies: 7
    Last Post: May 14th, 2012, 04:52 PM
  3. Need help with parameter passing in my project? (Beginner)
    By xlFireman in forum What's Wrong With My Code?
    Replies: 9
    Last Post: January 14th, 2012, 01:10 AM
  4. Passing JTextField as String parameter
    By Christophe in forum Java Theory & Questions
    Replies: 3
    Last Post: April 11th, 2010, 05:32 AM
  5. Passing objects as a constructor parameter
    By derky in forum Object Oriented Programming
    Replies: 2
    Last Post: October 27th, 2009, 04:31 AM