Is there a data structure in Java that can contain 4 or more values

Is there a data structure in Java that can contain more than 4 values?

So something like strings

Map<String, String, String, String>;

This is necessary in order to be able to reduce the number of if if else that I have. I would like to be able to do the following.

check if the data structure contains an element that matches a specific value, if it does, it assigns a link (which is a string) to a variable, and then adds the code and message to another variable that is associated with that link.

If not, is there a good workout to achieve this?

+4
source share
5

Java, 4 ?

.

, , String[], 4 , :

new String[4]

, ( ) .

, , ... ... , .

: , .

2: " Map<String, String, String, String>" , , .


. - , , - :

Map<String, MyRecord>;

public class MyRecord {
   private String link;
   private String code;
   private String message;

   // add constructor, getters, setters as required
}
+6

, ;

Multimap

Guava , .

+4

MultiMap Apache,

MultiMap - . . , ,

MultiMap mhm = new MultiValueMap();
mhm.put(key, "A");
mhm.put(key, "B");
mhm.put(key, "C");
Collection coll = (Collection) mhm.get(key);
+2

:

Map<String, Map<String, Map<String, String>>>
+1

, , "-". - "String", " " . - -, , ", ".

HashMap < String, Wrapper >  map;

Wrapper.java, ,

String link,code,message;

, getter, . Wrapper.java.

0

Source: https://habr.com/ru/post/1657972/


All Articles