Commit 375d1aae authored by I-Al-Istannen's avatar I-Al-Istannen
Browse files
parent cd0c240a
Pipeline #179227 failed with stage
in 15 minutes and 14 seconds
class ArrayIndexEvaluationOrder {
public int val;
public int[] arr;
public ArrayIndexEvaluationOrder init() {
this.arr = new int[20];
this.val = 0;
return this;
}
public int[] fetchArrWithSideEffect() {
val = 42;
return arr;
}
public int fetchIndexWithSideEffect() {
val = 21;
return 1;
}
public void check() {
fetchArrWithSideEffect()[fetchIndexWithSideEffect()] = 10;
System.out.println(val);
System.out.println(arr[1]);
}
public static void main(String[] args) {
new ArrayIndexEvaluationOrder().init().check();
}
}
class AssignmentEvaluationOrder {
public int x;
public int[] arr;
public AssignmentEvaluationOrder init() {
arr = new int[20];
x = 10;
return this;
}
public void check() {
arr[x = 5] = x;
System.out.println(arr[5]);
}
public static void main(String[] args) {
new AssignmentEvaluationOrder().init().check();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment