Java 将数组插入映射时出现UnsupportedOperationException

Java 将数组插入映射时出现UnsupportedOperationException,java,exception,collections,maps,unsupportedoperation,Java,Exception,Collections,Maps,Unsupportedoperation,在将数组插入映射时,我遇到一个不支持的操作异常。地图的输入是正确的。有没有合适的方法可以让我正确地插入并返回数据 public static Map<String, ProductClassPeriodData[]> getPeriodsByAgreement(String[] productClassIds,String agreementId) { Map data = Collections.EMPTY_MAP; for (in

在将数组插入映射时,我遇到一个不支持的操作异常。地图的输入是正确的。有没有合适的方法可以让我正确地插入并返回数据

    public static Map<String, ProductClassPeriodData[]> getPeriodsByAgreement(String[] productClassIds,String agreementId) 
    {
        Map data = Collections.EMPTY_MAP;
        for (int i = 0; i < productClassIds.length; i++)
        {
            ProductClassPeriodData[] periodData = getInstance().getProductClassPeriodsByAgreement(productClassIds[i], agreementId);
            data.put(String.valueOf(i), periodData);
        }
        return data;
    }
public静态映射getPeriodsByAgreement(String[]ProductClassID,String agreementId)
{
地图数据=Collections.EMPTY\u地图;
for(int i=0;i
集合。空映射是不可变的,不支持此操作

/**
 * The empty map (immutable).  This map is serializable.
 *
 * @see #emptyMap()
 * @since 1.3
 */
@SuppressWarnings("rawtypes")
public static final Map EMPTY_MAP = new EmptyMap<>();
/**
*空映射(不可变)。此映射是可序列化的。
*
*@see#emptyMap()
*@自1.3
*/
@抑制警告(“原始类型”)
公共静态最终映射EMPTY_Map=new EmptyMap();
改用

Map<String, ProductClassPeriodData[]> data = new HashMap<>();
Map data=newhashmap();