title: Java ternary operator is automatically wide casting an int to double during string concatenation
body: <p>I am trying to create a set of file paths using some numeric values from an array and read those files. The folders have the exact numeric values in their name except for when the value is 1.0. So if the value is 1.2 the folder is like</p>
  <blockquote>
  <p>data/text/1.2/</p>
  </blockquote>
  <p>When the value is 1.0 the folder is</p>
  <blockquote>
  <p>data/text/1/</p>
  </blockquote>
  <p>So I was trying to use the ternary operator and got an unexpected result. Here is the code -</p>
  <pre><code>double key = 1.0;
  String path = &quot;data/text/&quot; + (key == 1.0 ? 1 : key) + &quot;/&quot;;
  System.out.println(path);
          
  String path2 = &quot;data/text/&quot; + 1 + &quot;/&quot;;
  System.out.println(path2);
  </code></pre>
  <p>The output is as follows:</p>
  <blockquote>
  <p>data/text/1.0/</p>
  <p>data/text/1/</p>
  </blockquote>
  <p>Shouldn't the value in the first case also be?</p>
  <blockquote>
  <p>data/text/1/</p>
  </blockquote>
  <p>I expected that value since I am using the integer literal.</p>
  <p>Is this some kind of bug that in case of ternary operator the int value gets casted to double? Or am I getting somthing wrong?</p>