When java can implicitly do up casting , why does not it implicitly do down casting ?Please explain with some simple example?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
The point is that upcasting will always succeed, so it's safe - whereas downcasting can fail:
But:
Because it's a "dangerous" operation, the language forces you to do it explicitly - you're basically saying to the compiler "I know more than you do at this point!"