Credit goes to Blackcompe
If you are using the generic version of the list implementation, you don't need to cast, e.g.
ArrayList<BestTutor> list = null; BestTutor c = list.get(0); Generics is a type-safety method that tells Java nothing other than a BestTutor will go into this collection, so you can always bet that List.get() will return a BestTutor or whatever the bounded object is. BestTutor is called the bounded object. If you don't use generics the bounded object is Object., e.g.
ArrayList<Object> list; Although, this bounding is implicit, so it's just:
ArrayList list; Java will check to see if computeArea has been overridden. If it has it will use that version, else it will use the inherited version. e.g.
class Parent { void callMe(){ System.out.println("Parent"); } } class Child { void callMe(){ System.out.println("Child"); } } Child c = new Child(); c.callMe(); //will display Child It would call the Parent version, which would print Parent, but we overrode the method. That's basic overriding. Java also has polymorphism:
Parent p = new Child(); p.callMe(); //will display Child A reference of type Parent can refer to an instance of Child.
If you call a method of Parent that's been overridden by Child Java knows to call the Child's instance method, not the Parent's.
A little advanced, but that will really become useful in more advanced design methods, like "coding to interfaces".