Top 9 questions about Java Maps

In general, Map is a data structure consisting of a set of key-value pairs, and each key can only appears once in the map. This post summarizes Top 9 FAQ of how to use Java Map and its implemented classes. For sake of simplicity, I will use generics in examples. Therefore, I will just write Map instead of specific Map. But you can always assume that both the K and V are comparable, which means K extends Comparable and V extends Comparable.

Read more

Top 10 questions about Java Collections

The following are the most popular questions of Java collections asked and discussed on Stackoverflow. Before you look at those questions, it’s a good idea to see the class hierarchy diagram. 1. When to use LinkedList over ArrayList? ArrayList is essentially an array. Its elements can be accessed directly by index. But if the array … Read more

Java Reflection Tutorial

What is reflection? “Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine.” This concept is often mixed with introspection. The following are their definitions from Wiki: Introspection is the ability of a program to examine the type or properties … Read more

Top 10 Methods for Java Arrays

The following are top 10 methods for Java Array. They are the most voted questions from stackoverflow. 0. Declare an array String[] aArray = new String[5]; String[] bArray = {"a","b","c", "d", "e"}; String[] cArray = new String[]{"a","b","c","d","e"};String[] aArray = new String[5]; String[] bArray = {"a","b","c", "d", "e"}; String[] cArray = new String[]{"a","b","c","d","e"}; 1. Print an … Read more