13_Review Lecture

Lunchnode treenode btreenode l new lunchnode treenode

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: t;Double>(); list.add(5.5); // 5.5 is automatically converted to new Double(5.5) list.add(3.0); // 3.0 is automatically converted to new Double(3.0) Double doubleObject = list.get(0); // No casting is needed double d = list.get(1); // Automatically converted to double 16 Problem 1: Incorrect Parameter Types Node b = new Node();! TreeNode r = new TreeNode();! BTreeNode s = new BTreeNode();! Lunch<Node, TreeNode, BTreeNode> l = new Lunch<Node, TreeNode, BTreeNode>(b,r,s);! We want to more properly say the following: Lunch<subtypes of Meat, subtypes of Starch, subtypes of Soup>! 17 Problem 2: Inheritance of Generic Types •  ClassA extends ClassB •  Subtype Define Subclasses of Generic types not required! –  ClassA is a subtype of ClassB –  Stack<ClassA> is NOT a subtype of Stack<ClassB> •  Are we losing polymorphism? –  This creates trouble for us –  Customer...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online