Upcasting and Downcasting in java

后端 未结 8 1693
孤城傲影
孤城傲影 2021-01-13 21:26

I can understand what upcasting is but Downcasting is a little confusing. My question is why should we downcast? Can you help me with a real time example ? Is downcasting th

8条回答
  •  猫巷女王i
    2021-01-13 22:07

    With the introduction of generics, it is less important than it was before, but there are times when you need it.

    For instance, when you read an object from an ObjectInputStream.

提交回复
热议问题