日期:2014-05-18  浏览次数:20743 次

求教一个强制转换的问题!!
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);