• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what kind of statement it is?

 
kiran kumar reddy
Ranch Hand
Posts: 94
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, getServletConfig() returns an object. getInitParameter() is performed by the object that getServletConfig() returns.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 94
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeff Verdegan,
@Joel Christophel Thanks a lot guys now i understood it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic