-
Notifications
You must be signed in to change notification settings - Fork 0
6) Using Lists
pranithcodes edited this page Apr 6, 2018
·
1 revision
public static void main(String[] args) {
ArrayList<String> arrayList = new ArrayList<String>();
arrayList.add("IRONMAN");
arrayList.add("BATMAN");
arrayList.add("SUPERMAN");
arrayList.add("JOCKER");
JexlContext context = new MapContext();
context.set("list", arrayList);
context.set("out", System.out);
JexlEngine jexl = new JexlBuilder().create();
JexlExpression e = jexl.createExpression("out.println(\"3rd Element of array::\t \" + list.get(1))");
e.evaluate(context);
}
Similar to Arrays, we have define the ArrayList and add the list to the content. To access the elements of the list we can use get method directly.
“list.get(1))”