Java – store multiple values in the mapping of a single key
I have the following name in C: ght Txt, which contains the following data
Id|ytr|yts 1|W|T 2|W|T 3|W|T
The problem now is that the positions of these columns (ID | YTR | YTS) are not in order, which means that they can also shuffle
Id|ytr|dgfj|fhfjk|fgrt|yts
Or they can be like
Id|wer|ytr|weg|yts
So I did the following and read them in Java, as shown below
String[] headers = firstLine.split("|");
int id,Ix,Ixt,count = 0;
for(String header : headers) {
    if(header.equals("Id")) {
        idIx = count;
    }elseif (header.equals("Ix")) {
        Ixt = count;
    } elseif (header.equals("Ixt")) {
        Ixt = count;
    }
    count++;
}
Now I need to store them in a map to prevent ID. I will get the values of columns YTR and YTS, so there should be a single key in the map, but there may be multiple key values. Please tell me how to store them in the map
Solution
Using map < integer, list < string > > sounds like the first feasible method
Because it sounds like your value is structured, it may be better to create a value class, for example Map < integer, yourvalueclass > where
class YourValueClass
{
    String ix;
    String ixt;
    // constructor,getters and setters
}
Basically, you should consider classes / objects - not in object denial
The above is the whole content of Java - storing multiple values in the mapping of a single key collected by programming house for you. I hope this article can help you solve the program development problems encountered by Java - storing multiple values in the mapping of a single key.
If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.
