There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
J Solomon wrote:So the caller would be the section of code (most likely a method) where control is returned to when the method that you call to finishes executing?
Jeff Verdegan wrote:
J Solomon wrote:So the caller would be the section of code (most likely a method) where control is returned to when the method that you call to finishes executing?
I wouldn't even say that, since if an exception is thrown but not caught be the caller, then control return's to the caller's caller, or rather, to the nearest caller that does catch it.
Simply put, "caller" is basically what the standard English interpretation of the term implies. When we talk about "a method's caller", we mean the the code that called (invoked) that method. Depending on the context, we might be referring to the specific line or statement that executes the method call, or to the method, constructor, or initialization block that contains that line.
J Solomon wrote:
So if you make a call out to a method B from within a particular method A, method A would be the caller?
If you call out to a method from within a constructor or init block, would the class then be the caller?
Jeff Verdegan wrote:
J Solomon wrote:
So, for example, if I say, "If your method declares that it throws an unchecked exception, then the caller must either catch that exception, or also declare to throw it," do you understand what I mean by caller?
I think I have a better understanding now. Thanks again for all the help. This was definitely one question that I was not able to get a precise answer to from a text book and I wanted to make sure that I had a good understanding since I've seen it used quite a bit.
Normally trees don't drive trucks. Does this tiny ad have a license?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|