what is the difference between these 3?
def search(String id) {
//code
}
Object search(String id) {
//code
}
void search(String id) {
//code
}
specially between def
and Object
.
def
is an alias for Object
, so the first 2 signatures are identical.
the difference between the 1st two and the 3rd is, that you can return null or an instance of any class from the 1 and 2, whereas you can return only null from the 3rd one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With