Java Reference
In-Depth Information
The expression:
a = 6+1; a*2
returns 14.
Static fields and methods
With EL 3.0, it is now possible to directly access static fields and methods of a Java
class by using the syntax
MyClass.field
or
MyClass.method
, where
MyClass
is the name of the class that contains the static variable or method. The code that
follows demonstrates how to access the
MIN_VALUE
field of the
Integer
class and
how to parse the String
'2'
to
int
by using the static
parseInt
method of the
In-
teger
class:
ELProcessor el = new ELProcessor();
//static variable access
out.println("<h1> The value of
Integer.MIN_VALUE : "
+ el.eval("Integer.MIN_VALUE")
+ "</h1>");
//static method access
out.println("<h1> The value of
Integer.parseInt('2') : "
+
el.eval("Integer.parseInt('2')") + "</h1>");