Skip to main content

Practice ยท 2 of 3

Identity vs state, live

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).

Difficulty: advanced

Back to lesson: Practice: Memory drills