- 论坛徽章:
- 0
|
一个关于hashmap的疑问。。。
我都已经写了,可是我的get()同时还负责计算部分,下面就是程序,我想把A1的v直接赋给B2,可是测试通不过。
请指教
public class Sheet {
private HashMap hp = new HashMap();
private String out="";
/**
* @param string
* @return
*/
public Object get(String string) {
// TODO 自动生成方法存根
if (hp.containsKey(string)) {
Stock sto = (Stock) hp.get(string);
if(sto.toString().length()>;0&&sto.toString().charAt(0)=='=')
{Select outs = new Select(sto.toString().substring(1));
out = outs.select();
System.out.println("------->;" + out);
return out;
}
else
return sto.getstock();
}
return "";
}
/**
* @param theCell
* @param string
*/
public void put(String theCell, String string) {
// TODO 自动生成方法存根
if(string.length()>;0&&string.charAt(0)=='=')
{if(hp.containsKey(string.substring(1))){
hp.put(theCell,hp.get(string.substring(1)));
}
}else
hp.put(theCell, Stock.inputstock(string));
}
/**
* @param theCell
* @return
*/
public Object getLiteral(String theCell) {
// TODO 自动生成方法存根
if (hp.containsKey(theCell)) {
Stock sto = (Stock) hp.get(theCell);
return sto.toString();
}
return "";
}
} |
|