很急很急,又很棘手的问题,高手进
public int zhaoCi(HashMap hm,int zishu,char[] ch,int juli)
{
int i = zishu;
print( "zishu: "+zishu);
boolean bss = hm.containsKey(ch[i]);
print(bss);
if(bss&&hm.get(ch[i])!=null)
{
HashMap hMap = (HashMap)hm.get(ch[i]);
zishu=zishu+1;
juli=juli+1;
zhaoCi(hm,zishu,ch,juli);
}
else
{return juli;}
return juli;
}
java.lang.ClassCastException: java.lang.Character
at relative.zhaoCi(relative.java:183)
at relative.ciPinTongJi(relative.java:157)
at relative. <init> (relative.java:58)
at relative.main(relative.java:87)
HashMap hMap = (HashMap)hm.get(ch[i]);这条语句抛出错误,如何来获得一个MAP集的子MAP集合,然后在在找出下一个字符的所对应的子MAP集那,这个函数就是这样的一个递归函数,但是抛出异常,请求解决方法.请高手指教,很急很急!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
------解决方案--------------------SF
------解决方案--------------------关注
------解决方案--------------------class map
{
public void sercher(Map map,char[] ch)
{
ArrayList <Object> arraylist=new ArrayList < Object> ();
int len=ch.length;
Character[] charater=new Character[len];
for(int j=0;j <len;j++)
{
Character ct=new Character(ch[j]);
charater[j]=ct;
}
Set set=map.entrySet();
Iterator it=set.iterator();
while(it.hasNext())
{
Object cc=it.next();
arraylist.add(cc);
}
for(int i=0;i <len;i++)
{
if(arraylist.contains(charater[i]))
{
HashMap hm=(HashMap)map.get(charater[i]);
Set set1=hm.entrySet();
Iterator it1=set1.iterator();
while(it1.hasNext())
{
String str=(String)it1.next();
Object obj=hm.get(it1.next());
System.out.println(str);
System.out.println(obj);
}
}
else
{
System.out.println( "没有找到匹配的值 ");