小编sHa*_*aRi的帖子

计算地图中值的出现次数

我有以下类型的地图:

private HashMap<Integer, HashMap<String, Object>> entireMap;
Run Code Online (Sandbox Code Playgroud)

钥匙从1 - n开始.整个Map中的subMap具有以下类型:

HashMap<String, Object> subMap = new HashMap<String, Object>();
Run Code Online (Sandbox Code Playgroud)

整个地图的每个键都包含这个子地图(还有更多):

subMap.put("user_name", usid[1]);
Run Code Online (Sandbox Code Playgroud)

所以我最后有这样的事情:

{1 {"user_name" = "Arthur", "otherKeys = ..."}}
{2 {"user_name" = "Bela", "otherKeys = ..."}}
{3 {"user_name" = "Ceasar", "otherKeys = ..."}}
{4 {"user_name" = "Ceasar", "otherKeys = ..."}}
{5 {"user_name" = "Bela", "otherKeys = ..."}}
{6 {"user_name" = "Bela", "otherKeys = ..."}}
Run Code Online (Sandbox Code Playgroud)

现在我想计算整个Map中user_name的最大出现次数,在这种情况下它将是3(bela发生三次).

我怎样才能做到这一点?

java hashmap counting

3
推荐指数
1
解决办法
1610
查看次数

组合框中的 Apache POI 双值

我想要一个包含以下条目的组合框:

{"0,5", "1", "1,5", "2", "2,5"}

我使用数据验证:

    DataValidation dataValidation = null;
    DataValidationConstraint constraint = null;
    DataValidationHelper validationHelper = null;

    validationHelper = new XSSFDataValidationHelper(sheet);
    CellRangeAddressList addressList = new  CellRangeAddressList(row, row, col, col);
    constraint = validationHelper.createExplicitListConstraint(list);
    dataValidation = validationHelper.createValidation(constraint, addressList);
    dataValidation.setSuppressDropDownArrow(true);   
    sheet.addValidationData(dataValidation);
Run Code Online (Sandbox Code Playgroud)

该列表的结构如下:

列表 = new String[]{ "0,5", "1", "1,5", "2", "2,5" }

但生成 Excel 文件后,下拉列表中出现了其他内容。

0, 5, 1, 1, 5

这是为什么?

如果我使用点符号 (0.5, 1, 1.5),下一个问题是,当我从组合框中选择时,excel 自动将其格式化为日期,例如 1.5 -> 01。

java apache excel apache-poi dropdown

0
推荐指数
1
解决办法
1516
查看次数

标签 统计

java ×2

apache ×1

apache-poi ×1

counting ×1

dropdown ×1

excel ×1

hashmap ×1