Practice · 2 of 3
Identity vs state, live
CHALLENGE
Difficulty: advanced+25 XP
1. static boolean smallBoxedIdentity() — Integer a = 100, b = 100; return a == b;
2. static boolean largeBoxedIdentity() — Integer a = 500, b = 500; return a == b;
3. static boolean largeBoxedEquals() — same values, a.equals(b).
4. static int sameIdentityTwice() — build one List<String>, call
System.identityHashCode on it twice, return how many DISTINCT hash values you saw
(one — identity is stable).
Press Submit to check your solution.
Back to lesson: Practice: Memory drills