title: java.lang.Integer cannot be cast to java.lang.Byte error with Any type in Scala
body: <p>I can cast Int data to Byte.</p>
  
  <pre><code>scala&gt; 10.asInstanceOf[Byte]
  res8: Byte = 10
  </code></pre>
  
  <p>However with the same value in Any type, the cast raises an error.</p>
  
  <pre><code>scala&gt; val x : Any = 10
  x: Any = 10
  
  scala&gt; x.asInstanceOf[Byte]
  java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Byte
      at scala.runtime.BoxesRunTime.unboxToByte(BoxesRunTime.java:98)
      at .&lt;init&gt;(&lt;console&gt;:10)
  </code></pre>
  
  <p>I can cast twice.</p>
  
  <pre><code>scala&gt; val y = x.asInstanceOf[Int]
  y: Int = 10
  
  scala&gt; y.asInstanceOf[Byte]
  res11: Byte = 10
  </code></pre>
  
  <p>Are there better ways than this? </p>