Blog Archives

09: When to use which Java data structure? and why?

List, Set, Map, and Queue(access the ends FIFO or LIFO) are the basic Java data structure interfaces for which there are different implementations to cater for different usage patterns. Java data structure interview questions are very popular, and pays to know the differences. #1 Array (Employee[]) Vs List (List<Employee>):  Array…



9 Java Data structures best practices

#1: Choose the right type of Java data structure based on usage patterns

like fixed size or required to grow, duplicates allowed or not, ordering is required to be maintained or not, traversal is forward only or bi-directional, inserts at the end only or any arbitrary position, more inserts or more reads, concurrently accessed or not, modification is allowed or not, homogeneous or heterogeneous collection, etc. Also, keep multi-threading, atomicity, memory usage and performance considerations discussed earlier in mind.

#2: Favor unmodifiable data structures where applicable

Use an immutable collection (aka unmodifiable collection) if you don’t want to allow accidental …



300+ Java & Big Data FAQs - Quick Prep

Java & Big Data Tutorials

Top