I think you're in need of a HashMap , that's what it is usually used in Java to store related values by key - > value, as is the case you sample. The even values are entered in the map, once created, using the put
method. Maps do not support duplicate keys, that is, the values on the left can not be duplicated. You can see more details in the Java documentation .
In the example, you will see how to read a value by its code name. And you'll see two ways to read the entire map, before and after Java 8.
You can adapt your Map to any class, enter its values in arrays, in the database or wherever you want:
VIEW DEMO
Code
import java.util.*;
import java.lang.*;
class Rextester
{
public static void main(String args[])
{
String VALUE_MSSTORE_URL = new String ("Microsoft Store URL");
Map<String, String> map = new HashMap<String, String>();
map.put("Name", "DEAD OR ALIVE 5 Last Round Character: Zack");
map.put("Type", "---");
map.put("Descripcion Castellano", "Descarga este DLC para poder usar a Zack en la versión gratuita de DEAD OR ALIVE 5 Last Round...");
map.put("Descripcion Inglés", "Download this to use Zack in DEAD OR ALIVE 5 Last Round: Core Fighters.");
map.put("Descripcion Pegi", "Online Interactions Not Rated by the ESRB; Partial Nudity; Sexual Themes; Violence;");
map.put("Edad Pegi", "16+");
map.put("Edad Pegi USA", "Mature 17+");
map.put("Microsoft Store ID", "c3lcm7jmcs4q");
map.put("Microsoft Store URL", "c3lcm7jmcs4q");
System.out.println("\nBUSCANDO VALOR POR NOMBRE DE KEY\n");
System.out.println(map.get(VALUE_MSSTORE_URL));
System.out.println("\nLEYENDO TODO EL MAPA: ANTES DE JAVA 8\n");
for (Map.Entry<String, String> entry : map.entrySet())
{
System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());
}
System.out.println("\nLEYENDO TODO EL MAPA: JAVA 8\nforEach y lambda\n");
map.forEach((k,v)->System.out.println("Key : " + k + " Value : " + v));
}
}
Result
BUSCANDO VALOR POR NOMBRE DE KEY
c3lcm7jmcs4q
LEYENDO TODO EL MAPA: ANTES DE JAVA 8
Key : Descripcion Pegi Value : Online Interactions Not Rated by the ESRB; Partial Nudity; Sexual Themes; Violence;
Key : Edad Pegi USA Value : Mature 17+
Key : Type Value : ---
Key : Descripcion Inglés Value : Download this to use Zack in DEAD OR ALIVE 5 Last Round: Core Fighters.
Key : Microsoft Store ID Value : c3lcm7jmcs4q
Key : Edad Pegi Value : 16+
Key : Microsoft Store URL Value : c3lcm7jmcs4q
Key : Descripcion Castellano Value : Descarga este DLC para poder usar a Zack en la versión gratuita de DEAD OR ALIVE 5 Last Round...
Key : Name Value : DEAD OR ALIVE 5 Last Round Character: Zack
LEYENDO TODO EL MAPA: JAVA 8
forEach y lambda
Key : Descripcion Pegi Value : Online Interactions Not Rated by the ESRB; Partial Nudity; Sexual Themes; Violence;
Key : Edad Pegi USA Value : Mature 17+
Key : Type Value : ---
Key : Descripcion Inglés Value : Download this to use Zack in DEAD OR ALIVE 5 Last Round: Core Fighters.
Key : Microsoft Store ID Value : c3lcm7jmcs4q
Key : Edad Pegi Value : 16+
Key : Microsoft Store URL Value : c3lcm7jmcs4q
Key : Descripcion Castellano Value : Descarga este DLC para poder usar a Zack en la versión gratuita de DEAD OR ALIVE 5 Last Round...
Key : Name Value : DEAD OR ALIVE 5 Last Round Character: Zack