You’ll want a Map<String, String>
. Classes that implement the Map
interface include (but are not limited to):
Each is designed/optimized for certain situations (go to their respective docs for more info). HashMap
is probably the most common; the go-to default.
For example (using a HashMap
):
Map<String, String> map = new HashMap<String, String>(); map.put("dog", "type of animal"); System.out.println(map.get("dog"));
type of animal
Related Posts:
- What is a Key-Value Pair?
- Sort a Map
by values - A KeyValuePair in Java
- When to use a Map instead of a List in Java?
- Problem with gif with transparent background
- Search for words with telephone numbers from 2-3-4 tree
- Java 8 Iterable.forEach() vs foreach loop
- How to round a number to n decimal places in Java
- Where is JRE 11? [duplicate]
- How to convert/parse from String to char in java?
- How to set a Timer in Java?
- How to parse JSON in Java
- What is the difference between a static method and a non-static method?
- Is there a method that calculates a factorial in Java?
- What is Java Servlet?
- Generating a Random Number between 1 and 10 Java
- Generating a Random Number between 1 and 10 Java [duplicate]
- How do I generate random integers within a specific range in Java?
- Best way to convert an ArrayList to a string
- Does a Java to C++ converter/tool exist?
- How change the color arrowIcon to JMenu when it is selected
- “No X11 DISPLAY variable” – what does it mean?
- en_US or en-US, which one should you use?
- javac : command not found
- Java says FileNotFoundException but file exists
- Why am I getting InputMismatchException?
- Java integer list
- How can I properly compare two Integers in Java?
- element not interactable exception in selenium web automation
- How do I save a String to a text file using Java?
- method in class cannot be applied to given types
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- “NoClassDefFoundError: Could not initialize class” error
- Implements vs extends: When to use? What’s the difference?
- Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java
- How to override compareTo (Java)
- Why do I get an UnsupportedOperationException when trying to remove an element from a List?
- java.util.NoSuchElementException: No line found
- How to check whether a int is not null or empty?
- How to parse JSON in Java
- Declaring an unsigned int in Java
- Converting Hexadecimal String to Decimal Integer
- LocalDate to java.util.Date and vice versa simplest conversion?
- What is a Question Mark “?” and Colon “:” Operator Used for?
- How to remove single character from a String
- Shifting array to the right – homework
- How to get rid of Checkstyle message ‘File does not end with a newline.’
- Uri not Absolute exception getting while calling Restful Webservice
- Very Basic Java
- SQLRecoverableException: I/O Exception: Connection reset
- What exactly is a Maven Snapshot and why do we need it?
- How to check if my string is equal to null?
- what is Ljava.lang.String;@
- “Could not find Java SE Runtime Environment.” after installing Java
- How can I create an utility class?
- difference between ‘static int’ and ‘int’ in java
- How to use PrintWriter and File classes in Java?
- Error message “unreported exception java.io.IOException; must be caught or declared to be thrown”
- cannot make a static reference to the non-static field
- Proxy Error 502 : The proxy server received an invalid response from an upstream server
- Java double.MAX_VALUE?
- how to do a system pause in java for debugging?
- Immutable class?
- Is spring default scope singleton or not?
- Java Reflection – Object is not an instance of declaring class
- What does “AL lib: alc_cleanup: 1 device not closed” mean?
- Java Enum return Int
- int cannot be converted to int []
- Joda DateTime to Timestamp conversion
- break statement in “if else” – java
- What is the difference between JSF, Servlet and JSP?
- Get only part of an Array in Java?
- How to Get JSON Array Within JSON Object?
- What is a class constant?
- How to represent a fix number of repeats in regular expression?
- How to import a jar in Eclipse
- What is method hiding in Java? Even the JavaDoc explanation is confusing
- Java switch statement: Constant expression required, but it IS constant
- Resolving File paths – ‘File not found’ error in Eclipse
- Simple Coin Toss using random class in Java. The do while loop doesn’t seem to generate random results
- Why I am getting DefaultHttpClient is deprecated?
- When should you use multithreading? And would multi threading be beneficial if the different threads execute mutually independent tasks?
- How to Convert Int to Unsigned Byte and Back
- Suggestions needed: Effective Java to C source code converter
- Downloading a file from spring controllers
- Java Error Exception in thread “AWT-EventQueue-0” java.lang.StackOverflowError
- Write a program that reads an unspecified number of integers, determines pos, neg, total, average
- Parsing JSON string in Java
- java attempting to assign weaker access privilege error
- MessageBodyWriter not found for media type=application/json
- Conversion from Long to Double in Java
- Failed to find Java VM
- Java regex email
- Java Iterator on Doubly-linked-list
- Why “no projects found to import”?
- Java Swing setting JPanel Size
- how to use “tab space” while writing in text file
- Change Name of Import in Java, or import two classes with the same name
- C# Dictionary get item by index
- set background color: Android