1.
(1)<? super String> is any class which is a superclass of String (including String itself). (In this case, the only other suitable class is Object.)
即包括String的父类和它本身的类。
(2) <? extends String> (which in this specific case wouldn't be very useful as String is final, so it can have no subclasses).
即包括String的子类,而String没有子类,为null。
2
comparator是实现compare方法
comparable是实现compareto方法
3.
理论上subSet出来的Set只要你add进去的数在你subSet时候指定的区间之内就不会抛出异常了,你用jdk 1.6试试?
4.
我遇到的情况是直接List<String> list=new ArrayList();
在这种情况下,我们如果调用Collections.sort(list);方法,它会对list里字符串从左往右的字母的ascii值进行排序,不用实现 Comparator 接口
5.
public classBreaker2 {
2. staticString o= "";
3.
4. public static voidmain(String[] args) {
5. z: for(intx = 2; x < 7; x++) {
6. if(x == 3)
7. continue;
8. if(x == 5)
9. breakz;
10. o= o+ x;
11.}
12.System.out.println(o);
13.}
14.}
输出24
如果把continue改为break就会出错
6.
变量 不管你写什么 最后都是 public static final
方法 不管你写什么 最后都是 public abstract
接口里的东四 都是 public的
实现接口必须是public的
7.
Which can appropriately be thrown by a programmer using Java SE technology to create a desktopapplication?
A. ClassCastException
B. NullPointerException
C. NoClassDefFoundError
D. NumberFormatException
E. ArrayIndexOutOfBoundsException
Answer: D
本文详细解析了Java中的泛型使用,包括<?super T>和<?extends T>的区别,以及如何利用comparator和comparable接口进行集合排序。同时介绍了在特定条件下使用sort方法的注意事项。
3860

被折叠的 条评论
为什么被折叠?



