这是indexloc提供的服务,不要输入任何密码
Skip to content

组合一组对象为 Map , 偶数位对象为键, 奇数位对象为值. #3

@wave-gbt

Description

@wave-gbt
public static Map asMap(Object... objects) {
        Map m = new HashMap(16);
        for (int i = 0; i < objects.length; i += 2) {
            if (i + 1 < objects.length) {
                m.put(objects[i], objects[i + 1]);
            } else {
                m.put(objects[i], null);
            }
        }
        return m;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions