Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

treeset

843793Apr 15 2010 — edited Apr 15 2010
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?

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 13 2010
Added on Apr 15 2010
3 comments
211 views