This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""Bind Constructor Parameters"" Watch ""Bind Constructor Parameters"" New topic
Author

"Bind Constructor Parameters"

govind chettiar
Greenhorn

Joined: Mar 26, 2011
Posts: 4
In this ElementK training I'm doing on the section on constructors it enumerates the steps involved in constructing an object. The first step says "Bind Constructor Parameters".
Not understanding what this means I googled it and found out that it is from the Sun (Now Oracle) tutorials. Still not clear what it means. Would appreciate any insight...
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
It would be helpful if you'd post a link to what you don't understand or repeat it here, providing the source, of course. Add detail as necessary to describe what you don't understand. Just doing that may help you understand, but it'll definitely help us.


Always learning Java, currently using Eclipse on Fedora.
Linux user#: 501795
govind chettiar
Greenhorn

Joined: Mar 26, 2011
Posts: 4
Thanks for response!
I can't post a link since one needs to log on to access the training material but here I am posting the relevant transcript
Constructing and Initializing Objects
For object initialization first the memory is allocated and default values for the instance variables are assigned. Then, the instance variable initialization uses the following steps recursively:
1) Bind Constructor parameters
2) If explicit this(), call recursively, and then execute the body of the current constructor
3 more steps
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 561
This link does not use the term "Bind," but it does provide an overview of arguments and parameters in constructors and methods. I'm going to make a guess that "bind constructor parameters" means to assign the parameters passed to the constructor to the class fields and variables. For example,



the two lines I've written in the constructor "binds" the arguments passed to the constructor to the class fields of the same name.

As I said, I'm guessing. If it were a term I could find in the Sun/Oracle tutorials, I'd point you to it, but I couldn't find it. Besides, you can look as well as I can.
govind chettiar
Greenhorn

Joined: Mar 26, 2011
Posts: 4
I think that makes sense- use the parms in the constructor calls to set the values of the member attributes. Googling on that string "bind constructor parameters" gives a lot of hits one of which is the JavaRanch site where someone mentions that it is in the "official java book"
http://www.coderanch.com/t/519351/java-programmer-SCJP/certification/Constructor-cannot-call-instance-method

But virtually all the hits refer to this same text where I encountered it!

Thank you!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
That December 2010 posting has confused you. It is in fact possible to call instance methods from the constructor, but only after the super() call has been completed. It may not always be a good idea to call instance methods from the constructor, but it is possible.
govind chettiar
Greenhorn

Joined: Mar 26, 2011
Posts: 4
Thanks Campbell- I posted that older link not because I'd a question (or, as we say back in India, a doubt) about calling instance methods from w/in the constructor. I was just saying that in one of the responses to that post someone had mentioned the concept of "Bind constructor parameters"- topic of my original question.

Having said which I appreciate your insight- thanks for pointing it out!

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Bind Constructor Parameters"