作业

  1. Collection 接口和 Collections 类都是做什么用的 ?
  1. Collection 接口有几个子接口 ?Map 接口有父接口么 ?
  1. List 、 Set 、 Map 三个接口有什么特点 ?
  1. 请简述哈希表(散列表)
  1. 以下哪个集合接口支持通过字符串主键检索对象

    A.Map

    B.Set

    C.List

    D.Collection

  1. 以下哪些语句用于创建一个Map实例?

    A.Map m = new Map();

    B.Map m = new Map(init capacity,increment capacity);

    C.Map m = new Map(new Collection());

    D.以上均不行

  1. 以下代码的执行结果是?

    public class Example {
    
     public static void main(String[] args) {
    
         String s1 = "abc";
         String s2 = "def";
         String s3 = "def";
    
         List list = new ArrayList();
         list.add(s1);
         list.add(s2);
         list.add(s3);
         
         for (String string : list) {
             System.out.println( string );
         }
         
         System.out.println("-------------------");
         
         Set set = new HashSet<>();
         set.add(s1);
         set.add(s2);
         set.add(s3);
         
         for (String string : set) {
             System.out.println( string );
         }
     }
    }
    
  1. 以下代码执行结果是?TreeMap和 HashMap 的区别是什么 ?

    public class Example {
    
     public static void main(String[] args) {
    
         TreeMap map = new TreeMap();
         map.put("one", "1");
         map.put("two", "2");
         map.put("three", "3");
         displayMap(map);
    
     }
    
     static void displayMap(TreeMap map) {
    
         Collection c = map.entrySet();
         Iterator i = c.iterator();
    
         while (i.hasNext()) {
             Object o = i.next();
             System.out.print(o.toString());
         }
     }
    }
    
  2. Vector、ArrayList 和 LinkedList 有什么区别 ?

  1. Arrays.ArrayList 和 java.util.ArrayList 有什么区别 ?
  1. Hashtable和HashMap的区别
  1. 分别使用 HashMap 和 List 以及数组统计数组中相同的值出现的次数

    String[] array = {"abc" , "ABC" , "123" , "def" , "^_^" , "def" , "abc"};
    
  2. 请写出 Iterator 迭代器的优点

  1. 请写出循环 List 、Set、Map 的代码
  1. 以下哪个集合接口支持元素排序
A.Collection

B.Set

C.List

D.Map
  1. 为什么使用泛型 ?
  1. Java 虚拟机支持泛型么 ? 什么是泛型擦除 ?
  1. 怎么使用泛型 ?
  1. K , V 代表什么意思 ?
  1. 自定义类或者接口怎么使用泛型 ?

你可能感兴趣的:(作业)