Reputation: 451
Could you explain if there is any difference between type inference and type targetting or type targeting is just type inference? Thanks.
Upvotes: 2
Views: 1322
Reputation: 20641
I'm not sure what you mean by "type targetting", but "target type" is a thing. From the Java tutorial on type inference:
The target type of an expression is the data type that the Java compiler expects depending on where the expression appears
For instance, in the statement int a = b;
, the target type is int
- the expression, b
, should have a type of int
(or something convertible to it), because its context requires that.
"Type inference" by contrast is a process used to determine the type of an expression. The target type may be used as part of the type inference process.
Upvotes: 7