List<Employee> empLList = new LinkedList<>();
empLList.add(...)
Iterator<Employee> descItr = empLList.descendingIterator();
在上面的代码我无法与以下错误无法访问子类方法,是泛型的缺点吗?或者我失去了一些东西
cannot find symbol
symbol: method descendingIterator()
location: variable empLList of type List<Employee>
让我的descendingIterator有重铸empLList到链表
Iterator<Employee> descItr = ((LinkedList) empLList).descendingIterator();
我的问题访问的descendingIterator :一般来说,使用泛型的上述缺点是,即每次我们需要将对象转换回子类访问子类的方法,或者泛型应该像这样工作。
,或者我们不应该使用的情况下,仿制药,我们依靠太多的子类方法
还是我失去了一些东西
我很好奇在本例中使用泛型不是收藏用过的。
感谢@Azodious ...顺便说一句,我没有倒下你 – cjava