
下面这段代码在jdk1.5以上用泛型很好解决,但是我用的是jdk1.4请问如何解决泛型问题!!
protectedObjectgetCellString(Cellcell){Objectresult=null;if(cell!=null){intcellType=c...
protected Object getCellString(Cell cell){
Object result = null;
if (cell != null) {
int cellType = cell.getCellType();
switch(cellType){
case HSSFCell.CELL_TYPE_STRING :
result = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
result= cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_FORMULA:
result = cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_ERROR:
result=null;
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
result=cell.getBooleanCellValue();
break;
case HSSFCell.CELL_TYPE_BLANK:
result=null;
break;
}
}
return result;
} 展开
Object result = null;
if (cell != null) {
int cellType = cell.getCellType();
switch(cellType){
case HSSFCell.CELL_TYPE_STRING :
result = cell.getRichStringCellValue().getString();
break;
case HSSFCell.CELL_TYPE_NUMERIC:
result= cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_FORMULA:
result = cell.getNumericCellValue();
break;
case HSSFCell.CELL_TYPE_ERROR:
result=null;
break;
case HSSFCell.CELL_TYPE_BOOLEAN:
result=cell.getBooleanCellValue();
break;
case HSSFCell.CELL_TYPE_BLANK:
result=null;
break;
}
}
return result;
} 展开
展开全部
泛型无非就是让集合记住元素的类型
不用泛型的话,对象放入集合后类型就会变成project
取出来后用instanceof判断,然后强制类型转换就行了
不用泛型的话,对象放入集合后类型就会变成project
取出来后用instanceof判断,然后强制类型转换就行了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询