Need to store a 2d list but not using array

风流意气都作罢 提交于 2019-12-28 04:37:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!