Hi JKid, So that you can make use of the methods that the Set API provides you .
http://java.sun.com/j2se/1.3/docs/api/java/util/Set.html Would it have been HashSet you can use only these methods that HashSet API provides you http://java.sun.com/j2se/1.3/docs/api/java/util/HashSet.html Thanks, Ashok A V On Tue, Aug 4, 2009 at 10:15 PM, JKid314159<[email protected]> wrote: > Dear Java Programmer: > > public class FindDups { > public static void main(String[] args) { > Set<String> s = new HashSet<String>(); > for (String a : args) > if (!s.add(a)) > System.out.println("Duplicate detected: " + a); > > System.out.println(s.size() + " distinct words: " + s); > > Why is the newly created HashSet of String elements set as implicitly cast > to a string of Set. Why not write the following: > > HashSet<String> s = new HashSet<String>(); > > ? > ? > ? > Respects, > > JKid314159 > http://existentialists.blogspot.com/ > > > > > > > -- Victory belongs to the most persevering. - Napoleon --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
