I just figured out somewhere that there is a difference between widening conversion (implicit conversion) and numeric promotion (integer promotion). I checked out on the reliable websites, but couldn't find any specific difference for them. Is there any difference in java?
Asked
Active
Viewed 196 times
-5
-
Related: [The Java Language Specification](https://docs.oracle.com/javase/specs/jls/se12/html/index.html). – David Conrad Sep 03 '19 at 18:22
-
"figured out *somewhere*". "a difference", "reliable websites"; lot of *secrets*, hard to know exactly what the question is. The Java Language Specification (JLS), already posted, is probably the most reliable site (is the specification used to implement the language) and does explain all conversions – user85421 Sep 03 '19 at 18:24
-
Just asking if there is any difference between widening conversion and numeric promotion.....easy. – Jayesh Sonkusare Sep 03 '19 at 18:26
-
1*"I checked out on the reliable websites"* You should check the **most reliable** one, i.e. the one that *defines* the terms and describes what they mean, aka the [Java Language Specification](https://docs.oracle.com/javase/specs/). See e.g. sections [5.6.2. Binary Numeric Promotion](https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.6.2) and [5.1.2. Widening Primitive Conversion](https://docs.oracle.com/javase/specs/jls/se8/html/jls-5.html#jls-5.1.2). --- *FYI:* Widening conversion can also be explicit. – Andreas Sep 03 '19 at 18:44
1 Answers
2
Numeric promotion (unary and binary) is a higher-level operation than widening.
Promotion uses widening, e.g. (emphasis added):
The result is then promoted to a value of type int by a widening primitive conversion (§5.1.2) or an identity conversion (§5.1.1).
but other conversions are also applied where necessary, namely unboxing and value set conversion.

Andy Turner
- 137,514
- 11
- 162
- 243