例如,我經常看到這樣的:我什麼時候想要通過實際的類聲明接口?
Set<Integer> s = new TreeSet<Integer>();
Set<Integer> s = new HashSet<Integer>();
Map<Integer, String> m = new HashMap<Integer, String>();
在
TreeSet<Integer> ts = new TreeSet<Integer>();
HashSet<Integer> hs = new HashSet<Integer>();
HashMap<Integer, String> hm = new HashMap<Integer, String>();
有什麼優勢/前者VS後者的短處?
http://stackoverflow.com/questions/2026054/why-do-we-use-interface-is-it-only-for-standardization – Jayan 2012-08-11 03:12:00
其實,這是更相似:http://stackoverflow.com/questions/1484445/why-are-variables-declared-their-interface-name-in-java?rq = 1 – Zong 2012-08-11 03:13:22
@Zong Li:是的,其實這個是重複的。 – Jayan 2012-08-11 04:08:21