This tutorial deals with casting in java . If you don’t know how to use java variables, please check our corresponding java variables tutorial.
Casting in java is tightly related to assignement compatibility. So, we will deal with the assignment compatibility in depth in this tutorial before moving to java casting.
Assignment compatibility = what types can be assigned to other types.
it deals with numeric types: assigning lower range type to a larger range type.
Obviously we can assign an expression of a type to an lvalue expression of the same type.
A type of a larger range can contain the range of values that can represent a narrow type.
byte < short < (char)< int < long < float < double
The byte, long, float and double are signed.
The char type is unsigned. We cannot assign a byte or a short to a char and vice versa.
You may check the full casting in java tutorial to get more details about this subject.
There are others core java tutorials in that website that are very interesting.
Posted 1 March 2021
© 2021 TechTarget, Inc.
Powered by
Badges | Report an Issue | Privacy Policy | Terms of Service
Most Popular Content on DSC
To not miss this type of content in the future, subscribe to our newsletter.
Other popular resources
Archives: 2008-2014 | 2015-2016 | 2017-2019 | Book 1 | Book 2 | More
Most popular articles