Skip to Content
100 Java Mistakes and How to Avoid Them
book

100 Java Mistakes and How to Avoid Them

by Tagir Valeev
May 2024
Intermediate to advanced content levelIntermediate to advanced
352 pages
10h 45m
English
Manning Publications
Content preview from 100 Java Mistakes and How to Avoid Them

8 Collections and maps

This chapter covers

  • Common mistakes when adding or looking for an element of unrelated type in a collection
  • Handling nulls in collections and maps
  • Modifiable and unmodifiable collections
  • Concurrent modification of collections
  • Problems using the List.remove() method
  • How to implement iterators properly

The Java Collection API appeared long ago in Java 1.2. The world was quite different then: Java had no parameterized types (generics), mutable objects were in favor, and nulls were generally accepted values. Over time, the language and the way people write programs has changed significantly. Yet with all that change, the old collection API remains ubiquitous in modern programs. Some outdated design decisions negatively ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Complete Coding Interview Guide in Java

The Complete Coding Interview Guide in Java

Anghel Leonard
Java Coding Problems

Java Coding Problems

Anghel Leonard
Modern Java in Action

Modern Java in Action

Raoul-Gabriel Urma, Mario Fusco, Alan Mycroft

Publisher Resources

ISBN: 9781633437968Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentErrata PagePurchase Link