需要存储2d列表但不使用数组 [英] Need to store a 2d list but not using array
问题描述
考虑我有一个包含以下格式数据的txt文件:
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).
请建议任何更适合Java的收藏。另外请举个例子,因为我不熟悉Java。
Please suggest any better collection from Java suitable. Also please give an example as I am new to Java.
推荐答案
Java中的最佳选项是 Map< ; String,String>
。
Best option in Java is a Map<String, String>
.
由于非常紧急,请自行查看 MAP API 以及 Google搜索
As is so urgent, take a look by yourself in the MAP API and in this Google search
这篇关于需要存储2d列表但不使用数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!