Though the comments indicate the reason for having the two parameters, i really don't understand how they are being used. Is not the scope of the parameters limited to the someMethod() body? I haven't seen the anotherMethod() definition yet, but i believe it shouldn't matter.
Can someone help me understand this?
Thanks in advance
you should find that the primitive value doesn't change, but the Map's size does!
At first I thought you were asking about how they could make the parameters optional, and in case you don't know, you could just pass null arguments in place of the Object parameters (as long as that method was set up to handle null values when you didn't have anything to give it).
[ October 27, 2004: Message edited by: Stephen Huey ]
someMethod() has two parameters which are not being used within the method body. My original post has complete method definition as i found it. I just changed the method names. The method comments say the parameters are optional, sometimes they could be null. But within the method body since the parameters are not being used, are not they redundant? Can we not safely remove the paramters as shown below
I hope i was clearer this time. If not I will try to explain again.
It's possible that this class extends another class or implements an interface that defines that method signature, and this class is overriding/implementing it. If that's the case, removing the parameters will change the signature, most likely with detrimental results.
Originally posted by Shreyas Reddy:
The method comments say the parameters are optional, sometimes they could be null. But within the method body since the parameters are not being used, are not they redundant? Can we not safely remove the paramters[?]
If that method only exists in this class, I'd wonder what the author was thinking and perhaps suggest a better tag for the parameters: "ignored".
Typically, it's because you are implementing some interface with an implementation that doesn't need the parameters to determine the required behaviour. Other implementations might.
The same can be said for checked exceptions declared to be thrown on an interface method, though implementations should leave the declaration off if it is not used as a matter of form.