[Java] Assign same value to different variables - trick question incl.
JavaShortSeries
11 December, 2023
36
36
0
Contributors
Example
public class PlayGround {
public static void main(String[] args) {
int x, y;
x = y = 9;
System.out.println(x + " " + y); // prints out 9 9
}
}
- Here's a question - comment your answer down below
Question - What are the values of i & the array nums?
public class PlayGround {
public static void main(String[] args) {
int i = 0;
int[] nums = new int[] { 7, 8 };
nums[i] = i = 1;
// What are the values of i & the array nums?
}
}
java