How do i typcast array of Object into array of Fruit when i know that array of Object contains Fruit Objects. Please help its very urgent for me as i have submit a code
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; at ArrayTypeCasting.main(ArrayTypeCasting.java:23)
What you have assigned to oArray is not an array of Fruit references, it is an array of Object references that contains a reference to a Fruit. Here's my go at correcting your problem: