This discussion is archived
3 Replies Latest reply: Apr 15, 2010 12:11 AM by Kayaman RSS

treeset

843793 Newbie
Currently Being Moderated
TreeSet<String> s = new TreeSet<String>();
          TreeSet<String> subs = new TreeSet<String>();
           s.add("a"); s.add("b"); s.add("c"); s.add("d"); s.add("e");
          
           subs = (TreeSet) s.subSet("b",true, "d",true);  //1
           
           System.out.println(s +" "+ subs);
in line 1 it returns navigableSet but it is casted to treeset which is a subclass of navigableset so
why doesn't it returns classcastexception?