Meaningless Drivel is fun!
The moose likes Beginning Java and the fly likes y do v need casting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "y do v need casting" Watch "y do v need casting" New topic

y do v need casting

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
if int &float have the same numbers of bytes then y do v need to do casting between them
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
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.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link:
subject: y do v need casting
It's not a secret anymore!