Java Map from Array map(Object... objs)

Here you can find the source of map(Object... objs)

Description

map

License

Open Source License

Declaration

public static Map map(Object... objs) 

Method Source Code

//package com.java2s;

import java.util.HashMap;

import java.util.Map;

public class Main {
    public static Map map(Object... objs) {
        return toMap(objs);
    }// w  ww .  j  av  a2 s . co  m

    public static Map toMap(Object... objs) {
        Map map = new HashMap();
        Object key = null;
        for (int i = 0; i < objs.length; i++) {
            if (i % 2 == 0) {
                key = objs[i];
            } else {
                map.put(key, objs[i]);
            }
        }
        return map;
    }
}

Related

  1. map(Object... keyvals)
  2. map(Object... mapValues)
  3. map(Object... objects)
  4. map(Object... objects)
  5. map(Object... objects)
  6. map(Object... objs)
  7. map(Object... oo)
  8. map(Object... params)
  9. map(String k, Object v)