gpt4 book ai didi

java - 如何从Java Maps(多层关联数组)中获取键、值

转载 作者:行者123 更新时间:2023-12-01 23:19:41 24 4
gpt4 key购买 nike

我有以下数组( map ):

Map<String, String[]> fields = new HashMap<String, String[]>();
fields.put( "memberDOB", new String[]{ "true", "", "", "2", "date"} );
fields.put( "memberDOJ", new String[]{ "true", "", "", "2", "date"} );
fields.put( "membershipDate", new String[]{ "true", "", "", "2", "date"} );
fields.put( "txtAccountNo", new String[]{ "true", "1", "10", "1", "int"} );
fields.put( "txtMemIntro1Address", new String[]{ "true", "5", "", "1", "string"} );

validate validateF = new validate();
if(validateF.validate_fields(fields)){
//validated
}

检索值和键:

public boolean validate_fields(Map<String, String[]> fields) {
//How to loop through each key
return true;
}

最佳答案

您可以使用:

for (String key : fields.keySet()) {
// key iterate over all keys in fields
}

关于java - 如何从Java Maps(多层关联数组)中获取键、值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20771407/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com