aspose file tools*
The moose likes Beginning Java and the fly likes what kind of statement it is? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what kind of statement it is?" Watch "what kind of statement it is?" New topic
Author

what kind of statement it is?

kiran kumar reddy
Ranch Hand

Joined: Jun 28, 2012
Posts: 94

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: 61766
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joel Christophel
Ranch Hand

Joined: Apr 20, 2011
Posts: 241
    
    1

In other words, getServletConfig() returns an object. getInitParameter() is performed by the object that getServletConfig() returns.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

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: 94

@Jeff Verdegan,
@Joel Christophel Thanks a lot guys now i understood it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what kind of statement it is?