当前位置: 代码迷 >> Java Web开发 >> 求教一个强制转换的有关问题!
  详细解决方案

求教一个强制转换的有关问题!

热度:8   发布时间:2016-04-17 14:16:53.0
求教一个强制转换的问题!!
String   toLink   =   request.getParameter( "toLink ");
    HashMap   hm   =   new   HashMap();
    int   count   =   0;
    if   (application.getAttribute( "links ")   !=   null)   {
        hm   =   new   HashMap((HashMap)   application.getAttribute( "links "));
        if(hm.get(toLink)!=null){
            count   =   Integer.parseInt(hm.get(toLink).toString());
        }
    }
    hm.put(toLink,   new   Integer(count   +   1));
    application.setAttribute( "links ",   hm);
    response.sendRedirect(toLink);
.
.
.
.
HashMap   hm   =   new   HashMap((HashMap)   application.getAttribute( "links "));
Integer[]   o   =   (Integer[])   hm.values().toArray();
此时出现异常:ClassCastException

请问如何能解决呢?!!
我的目的是转成:   Integer[]   或   int[];


------解决方案--------------------
Integer[] o = new Integer[hm.size()];
hm.values().toArray(o);
  相关解决方案