我有一个Hashmap的ArrayList,其中我有像name,phoneNo,Date,Age ....等键.
我想根据日期字段对Hashmap进行排序.
如果我使用LinkedHashMap,那么它也没用,因为我以随机方式获取值.
我不能使用对象而不是HashMap,因为我不知道我将获得多少条目.我动态地放置键和值.
我如何从另一个中得到List<Object> filteredList
id(Object.id
)包含的内容.考虑到适度的数据量,在解决这个问题的时候,有效和高效的方法是什么.List<id> idsList
List<Object>allObjects
我正在使用java6
"集合","集合"和"集合"之间的区别
在java.util包中,我们将使用这三个关键字,因此这些关键字之间有什么区别.1)收集2)收集3)收藏.
collection:它是word表示Collection Object和Map对象.
集合:它是所有集合的超级接口,即以阵列格式.
集合:它是类,包含操作Collection Object的Utility方法.
谁能帮我?例
代码段:
a.intersect(b).print()
// Result 1 . twin between two object
a.merge(b).print()
// Result 1,2,3,4,5
Run Code Online (Sandbox Code Playgroud)
请更正我的任务:/***@param args命令行参数*/
public static void main(String[] args) {
// TODO code application logic here
Set<Integer> a = new TreeSet<Integer>();
a.add(1);
a.add(2);
a.add(6);
a.remove(2);
a.add(1); //gak berpengaruh karena sudah ada yang 1 sebelumnya
//mengapa begituu ? karena et adalah collection yang tidak dapat memiliki elemen kembar.
System.out.println("A = " + a);
Set<Integer> b = new TreeSet<Integer>();
b.add(2);
b.add(6);
b.add(1);
System.out.println("B = " …
Run Code Online (Sandbox Code Playgroud) 像这样的东西:
string defectGuid = null;
var dictionary = new Dictionary<bool,string> {
{new ProjectDiscrepancyWrongLocation().Conditions(row), "88ff2dfb-6190-4ab6-b13b-68de1719eac2"},
{new DestructionLeakiness().Conditions(row), "af018ee7-7974-45f8-a508-18359cde4108"},
{new CoatingInsulationDefect().Conditions(row), "232b2b2e-abc0-46b2-8b8c-45fede83ad83"},
{new CathodicProtectionUnitUnderProtectionZone().Conditions(row), "78cb3548-0d61-4809-bf28-0590dfb52010"},
{new CoatingPaintDefect().Conditions(row), "83e82b20-efc9-4500-8ca5-bb29631ccc61"},
{new ProjectDiscrepancyEdgesOffset().Conditions(row), "cf9c76c3-79eb-4856-8dc6-c9c7321a3ed5"},
{new DocumentationDiscrepancyDiscrepanciesInDocumentation().Conditions(row), "d3c793bc-5840-413a-8cae-6962772b4a88"},
{new DestructionElementDestruction().Conditions(row), "6b8924f9-5bba-4db8-b33c-099ca17a58b9"},
{new IndicatorDefectDamage().Conditions(row), "8F2560F3-31A0-4489-9A77-387BE9347D38"}
};
foreach (var item in dictionary.Where(item => item.Key)) {
defectGuid = item.Value;
}
return defectGuid;
Run Code Online (Sandbox Code Playgroud)
其中一个类如下:
public class DestructionLeakiness : IDefectTypeConditions {
public bool Conditions(string[] row) {
return Helpers.NormalizeLocalizedString(row[4]).Contains("aaaa");
}
}
Run Code Online (Sandbox Code Playgroud)
问题是会出现一个错误,表明密钥已经存在.
更新:
我改变了以下方法:
private static string SetTypeOfDefect(string[] row)
{
string defectGuid …
Run Code Online (Sandbox Code Playgroud) 我们可以在hashMap中放入单个null键.但是在linkedHashMap中我们不能拉空键.这背后的原因是什么?