Nine Core Java Questions

My previous post with Eight Core Java Questions was popular so I created nine more. Please join the discussion of the answers for these questions on Twitter 1. Comment on this question How many elements does this set have? Set set = new HashSet(Arrays.asList( -0, +0, -0L, +0L, -0F, 0F, -0D, 0D, 0xF, 0xD, 0x0.DP+0)); System.out.println(set.size()); 12 1 6 9 2. Comment on this question This compiles in Java 17 due to static int[] a(int[]... a)[] { return a; } static final int one = a(new int[0]).length; // 1 It confuses the compiler It’s a static method Backward Compatibility JEP 747 3. Comment on this question The code below prints "23 & 52" the following due to System.out.println( new BigDecimal(2.008f).toString().length() + " & " + new BigDecimal(2.008).toString().length()); A bug in Java 23 The randomness of floating-point Length of the mantissa Magic numbers