Reputation: 773
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
.
Upvotes: 11
Views: 8278
Reputation: 20699
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.
Upvotes: 19