| Author |
what kind of statement it is?
|
kiran kumar reddy
Ranch Hand
Joined: Jun 28, 2012
Posts: 41
|
|
while studying init parameters concept in HF servlets and jsp i came across a stateement as follows
getServletConfig().getInitParameter("adminEmail")
the one which is underlined .
i know we can call methods using class names like A.method() or using objects like a.method() the one which is underlined above is kind off confusing for me. does it mean a method calling a method??
help me out guys. thanks in advance
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56151
|
|
Moved to Beginning Java as this really has nothing to do with servlets.
That's just method chaining. The first method returns a reference to an object instance, and the second method is called on that object. That way, there is no need for a temporary variable to hold the object reference if it's not needed for anything else.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Joel Christophel
Ranch Hand
Joined: Apr 20, 2011
Posts: 119
|
|
In other words, getServletConfig() returns an object. getInitParameter() is performed by the object that getServletConfig() returns.
|
 |
Jeff Verdegan
Bartender
Joined: Jan 03, 2004
Posts: 5791
|
|
Joel Christophel wrote:In other words, getServletConfig() returns an object.
Actually it returns a reference to an object. Among experienced developers it's common to blur the distinction for brevity's sake, when we all know what we mean, but for beginners, it's best to keep that distinction explicit, as it can be the source of a lot of confusion and misconceptions.
|
 |
kiran kumar reddy
Ranch Hand
Joined: Jun 28, 2012
Posts: 41
|
|
@Jeff Verdegan,
@Joel Christophel Thanks a lot guys now i understood it.
|
 |
 |
|
|
subject: what kind of statement it is?
|
|
|