order an array of obkect java code example

Example 1: lopp array java

For(<DataType of array/List><Temp variable name>   : <Array/List to be iterated>){
    System.out.println();
//Any other operation can be done with this temp variable.
}

Example 2: graal.js javascript array in java

Context context = Context.newBuilder("js").build();
Value result = context.eval("js", "var list=[1,2,'foo',true]; list;");
if (result.hasArrayElements()) {
    for (int i=0;i<result.getArraySize();i++) {
        System.out.println(result.getArrayElement(i));
    }
}