Just import java.util;
is incomplete b/c it’s only the package
part.
In order to actually import class
LinkedHashMap, we have to include it after the package
path:
import java.util.LinkedHashMap;
Alternatively, though not a good practice, we can import the whole “java.util” package
via *
:
import java.util.*;
For more type flexibility, it’s advisable to declare a variable w/ the corresponding interface
type instead; for this case a Map:
import java.util.Map;
import java.util.LinkedHashMap;
public final Map<String, String> dict = new LinkedHashMap<>();
By doing so, your LinkedHashMap can be more easily passed around to other functions as if it were any other Map; but still keeping its features.