Type inference is a feature of generic methods which allows you to call them as if they were drdinary methods i.e.
without specifying the type in between <>. For example:
public <E> boolean oneBiggerThanTwo(E one , E two){
return Util.compare(one, two);
}
Then we can call it by:
boolean bool1 = <Integer>oneBiggerThanTwo(Integer.valueOf(12), Integer.valueOf(37))
Type inference means that there is no need to specify type parameters when calling a function as compiler will do it for you
'Java - English ver' 카테고리의 다른 글
| Writing generic classes (0) | 2024.11.09 |
|---|---|
| Using bounded type parameters in generic methods (3) | 2024.11.08 |
| Writing generic methods (0) | 2024.11.06 |
| Writing genenric methods (0) | 2024.11.05 |
| Wildcards Extras (0) | 2024.11.04 |