11. public void addStrings(List list) { 12. list.add(”foo”); 13. list.add(”bar”); 14. } What must you change in this method to compile without warnings?()
- A、 add this code after line 11: list = (List
) list; - B、 change lines 12 and 13 to: list.add
(”foo”); list.add (”bar”); - C、 change the method signature on line 11 to: public void addStrings(List< extends String> list) {
- D、 change the method signature on line 11 to: public void addStrings(List< super String> list) {
- E、 No changes are necessary. This method compiles without warnings.
正确答案:D
答案解析:有
微信扫一扫手机做题