Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

y do v need casting

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if int &float have the same numbers of bytes then y do v need to do casting between them
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because Java is a "strongly typed language". Basically that means that when you declare a variable in Java you must name the type of thing that can go in it. And that is the ONLY thing that can go in it. Some languages allow sort of generic variables that can hold an assortment of stuff - but not java.
Therefore if you want to put something that is a different "type" into your variable you must "promise" the JVM that it will fit by casting.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic