AITeky Learn

AiTeky Original Interactive Learning & Practice Intermediate

Java: equality contracts, garbage collection and latency spikes

See why two objects that "look equal" can still be lost in a hash-based collection unless equals and hashCode agree, how the garbage collector's work follows how fast you create objects, and track down a service whose slow requests come in bursts.

Java runs on the JVM, a runtime that manages memory for you with a garbage collector. That removes whole classes of faults from C and C++, and it leaves two Java-specific traps that catch experienced developers: objects that are not equal when they should be (and the hash collections that then lose them), and pauses caused by the collector when a program creates objects faster than it needs to.

This course models both with small Python programs you can run in your browser. Python stands in for Java: the code is not Java, but the contracts and the counts it shows are those of the real language and runtime. Check the Java documentation for exact syntax and for the collectors in your Java version. All numbers are made up.

  • Learn lessons explain one idea at a time and let you run it.
  • Industry ready lessons decide and justify, and end with interview questions.

No Java experience is assumed. Basic Python helps.

Locked. Sign up free

Learn

Understand each idea with everyday examples. No coding background needed.

  1. 00 25 min 🔒 AiTeky Pass Start here: objects, references and equality See that a variable holds a reference to an object, not the object itself, and learn the difference between two names for one thing and two things that look alike.
  2. 01 30 min Free sample 🔒 AiTeky Pass equals and hashCode must agree Put objects with three different definitions of equality into a hash-based set, see which ones can be found again, and learn the contract (equal objects must have equal hash codes) and why changing a key's fields after inserting it loses it.
  3. 02 30 min 🔒 AiTeky Pass The garbage collector follows your allocations Model a young generation that fills and is cleaned often, an old generation that fills slowly and is cleaned rarely but with a long pause, and see how the rate you create objects, how long they live, and the size of the heap decide how often and how long the program freezes.

Industry ready

Real problems from real jobs, and the questions interviewers ask about them.

  1. 03 35 min 🔒 AiTeky Pass On the job: the slow requests that come in bursts A Java service averages 25 ms but a few requests a minute take almost a second. Model its collector pauses, compare four fixes (create fewer objects, shrink the in-memory cache, a low-pause collector, a bigger heap) by slow pauses per hour, effort and risk, choose, and write the investigation note.

We use essential cookies to run the site. With your permission we also set one anonymous ID to count unique visitors, and analytics cookies to see which pages help learners. Cookie notice

Join AiTeky Learn. It's free.

Create a free account to track your progress, save items for later and get study suggestions.

Sign up free Log in