4 ms·
A java cast is fundamentally different from a c cast, if thats what you're aiming at. In C, you ask the compiler to treat a memory location differently (in some
by ablob 3y ago
A java cast is fundamentally different from a c cast, if thats what you're aiming at.
In C, you ask the compiler to treat a memory location differently (in some cases it also implies a conversion), while in java you ask the compiler to check, whether an object is of a specific type and only if it is, then you get to treat that object in that way.
Edit: casts and conversions are unfortunatelly written the same way
This is what is meant when people say that Java is type-safe. If you cast a car into a bird a java program will enter a failure-mode, while the C program will tag along happily without further notice.