Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ResponseEntity<?> and ResponseEntity are not the same?

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.

like image 290
Dan Brandt Avatar asked Dec 03 '22 19:12

Dan Brandt


2 Answers

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.

like image 35
20 fps Avatar answered Dec 31 '22 17:12

20 fps


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.

like image 142
Afaq Ahmed Khan Avatar answered Dec 31 '22 16:12

Afaq Ahmed Khan