Array and metod in SpEL by R4R Team

Array and metod in SpEL:-

Arrays can be built using the familiar Java syntax are as follows:

int[] num1 = (int[]) parser.parseExpression("new int[4]").getValue(context);

//Array with initializer

int[] num2 = (int[]) parser.parseExpression("new int[]{1,2,3,4}").getValue(context);

//Multi dimensional array

int[][] num3 = (int[][]) parser.parseExpression("new int[4][5]").getValue(context);

Methods are invoked using typical Java programming syntax. You may also invoke methods on literals.

//string literal, evaluates to "pu"

String c = parser.parseExpression("'vipul'.substring(3, 4)").getValue(String.class);

//evaluates to true

boolean isMember = parser.parseExpression("isMember('Vipul Sharma')").getValue(

societyContext, Boolean.class);

Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!