title: Use of type cast operator within print statement
body: <p>I am having difficulty understanding why the following returns a syntax error in Java:</p>
  
  <pre><code>int integer1 = 5;
  System.out.print("The value of integer1 is " + (String)integer1);
  </code></pre>
  
  <p>I've noticed that to bypass this error I could just create a new String variable initialized to the typecast value of integer1:</p>
  
  <pre><code>int integer1 = 5;
  String cast = (String)integer1;
  System.out.print("The value of integer1 is " + cast);
  </code></pre>
  
  <p>but this seems a bit unnecessary, especially if I'll only be displaying the value of the integer once.</p>