cover-img

[Java] Assign same value to different variables - trick question incl.

JavaShortSeries

11 December, 2023

36

36

0

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

36

36

0

java

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.