需要存储二维列表但不使用数组 [英] Need to store a 2d list but not using array

查看:27
本文介绍了需要存储二维列表但不使用数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个包含以下格式数据的 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.

Best option in Java is a Map<String, String>.

既然这么急,自己去MAP API 并在此 谷歌搜索

As is so urgent, take a look by yourself in the MAP API and in this Google search

您也可以使用 Set,做我的客人,看看这个链接

这篇关于需要存储二维列表但不使用数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆