Polymorphism: CS 310 Lecture notes

Object-Oriented Programming with Java Lecture Notes

19 February 2009 • Polymorphism


For example, the JavaAPIRef(util, Arrays, sort(java.lang.object[])) accepts an array of objects rather than an array of Comparables. It's not clear why this is so; the sort is eventually going to downcast the array elements to Comparables, which means a successful sort required an array of Comparables. Replacing sort(Object []) with sort(Comparable []) would seem to be backwards compatible, at least for the successful cases.


This page last modified on 24 January 2006.