首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

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

2011-11-23 
求教一个强制转换的问题!!StringtoLinkrequest.getParameter( toLink )HashMaphmnewHashMap()intcou

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

热点排行