Reputation: 615
I know that raw types are bad in code, and List<?>
and List
, for example, are different things. But what about situation with ResponseEntity<?>
and ResponseEntity
? Using in @RestController
.
Upvotes: 7
Views: 16082
Reputation: 495
ResponseEntity<?>
is read-only. You can not write to it. However, the raw type ResponseEntity
is writeable.
Upvotes: 3
Reputation: 342
ResponseEntity<?>
it's kinda trick for IDE, so it's not gonna say you have raw type in your code.
So they are actually absolutely the same, anyway I'd suggest you do not use raw type and provide generic types for any of you response entities.
Upvotes: 3
Reputation: 2302
They are actually the same, compiler would replace it with generic type, if you see here in the documentation ResponseEntity it's actually
class ResponseEntity<T>
so ResponseEntity<?>
and ResponseEntity
are the same.
Upvotes: 13