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

Timo Hahn
Answer

You can you an EL that is pointing to a bean that returns the current year as a string. Like EL:

<af:outputText id="footSp" value="Copyright © #{Mybean.currentYear}">

and in the MyBean java class

public String getCurrentYear() {
// do the calculation to get the current year
String year = ...
return year
}

Now, each time you use this outputtext you get the copyright with the current year.

Timo

Marked as Answer by Timo Hahn · Jan 26 2023
Neha Narkhede

@timo-hahn1 Thanks for the reply.
So there is no alternative way to get year from direct EL expression? That way I can avoid bean binding.

Timo Hahn

Sure, you can create a method in the application module that returns the year. Then you can use the return value inside an EL.
The solution using a bean is simpler to implement.

Timo

1 - 3
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
215 views