Overcasting in java

Status
Not open for further replies.
I believe you mean 'cast' instead of 'overcast'. Casting simply allows you to use an object or primitive as a different type, but there are several restrictions. A simple casting example is shown below.
Code:
double x = 1.234;
int y = (int)x; // y equals 1
You can also cast an object to a parent type in it's inheritance hierarchy or to an implemented interface in the hierarchy. If you aren't familiar with inheritance or interfaces, you may want to learn about those concepts first.
 
Status
Not open for further replies.
Back
Top Bottom