You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
742 B
22 lines
742 B
public class TestCache {
|
|
public static void main(String[] args) {
|
|
Cache<String, Integer> cache = new Cache<>();
|
|
|
|
cache.put("张三", 85);
|
|
cache.put("李四", 90);
|
|
cache.put("王五", 78);
|
|
|
|
System.out.println("张三的分数:" + cache.get("张三"));
|
|
System.out.println("李四的分数:" + cache.get("李四"));
|
|
|
|
cache.remove("王五");
|
|
System.out.println("王五的分数:" + cache.get("王五"));
|
|
|
|
|
|
System.out.println("是否包含张三:" + cache.containsKey("张三"));
|
|
System.out.println("缓存大小:" + cache.size());
|
|
|
|
cache.clear();
|
|
System.out.println("清空后大小:" + cache.size());
|
|
}
|
|
}
|
|
|