问题
Consider that I have a txt file containing data of the following format:
"Home" "A1"
"Car" "A2"
"Home" "B1"
"Home" "A1"
"Car" "A2"
"Man" "B1"
How I can store this kind of data and also in sorted format, without duplicate data? But The first and third element must not be deleted as they are different with 2nd parameter (repetition of second parameter is allowed but not both 1st and 2nd).
Please suggest any better collection from Java suitable. Also please give an example as I am new to Java.
回答1:
Best option in Java is a Map<String, String>
.
As is so urgent, take a look by yourself in the MAP API and in this Google search
Also you can use Set, be my guest and take a look into this Link
回答2:
I would recommend Map<String, String>
. If you have time, read THIS
来源:https://stackoverflow.com/questions/32140476/need-to-store-a-2d-list-but-not-using-array