Java集合类 [英] Java collection classes

查看:65
本文介绍了Java集合类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Collection类HashSet扩展了AbstractSet类.它还实现了Set接口.
但是,由于AbstractSet类已经实现了Set接口,那么为什么需要HashSet再次实现它呢? HashSet以不同的方式实现它.接口保持不变,实现更改,因为HashSet功能不同.对基类的某些接口方法的这种重新实现是接口实现的一种常见技术.

—SA


The Collection class HashSet extends the AbstractSet class . Also it implements the Set interface.
But as the AbstractSet class already implements Set interface, then why there is a need for HashSet to implement it again ?

解决方案

Nothing wrong here; HashSet implements it in a different way. Interface remains the same, implementation changes, because HashSet features are different. Such re-implementation of some interface methods of base class is quite a usual technique of interface implementation.

—SA


这篇关于Java集合类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆