1、方法中的泛型
| 代码如下 | 复制代码 |
publicstatic
FileInputStream fis =null; ObjectInputStream ois =null; Object obj =null;
try{
fis =newFileInputStream(path + fileName); ois =newObjectInputStream(fis); obj = ois.readObject();
}catch(FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch(ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch(IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{
try{ if( fis!=null) fis.close(); if( ois!=null) ois.close(); }catch(IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
}
return(T)obj; } | |
2、定义泛型类
| 代码如下 | 复制代码 |
publicclassPageHibernateCallback
privateString hql; privateObject[] params; privateintstartIndex; privateintpageSize;
publicPageHibernateCallback(String hql, Object[] params, intstartIndex,intpageSize) { super(); this.hql = hql; this.params = params; this.startIndex = startIndex; this.pageSize = pageSize; }
publicList SQLException { //1 执行hql语句 Query query = session.createQuery(hql); //2 实际参数 if(params !=null){ for(inti =0; i < params.length ; i ++){ query.setParameter(i, params[i]); } } //3 分页 query.setFirstResult(startIndex); query.setMaxResults(pageSize);
returnquery.list(); }
} | |
解忧小村落最新版2024
解忧小村落游戏是非常好玩的一款休闲放置经营类型的手游,在这里
洋果子店rose2中文版
洋果子店rose2中文版是一款非常好玩的模拟经营手游,精美的
我的世界国际版测试版最新版
我的世界国际测试版模组,一款经典像素题材的沙盒模拟游戏,在
我的世界地下城手机版(Minecraft Dungeons)
我的世界地下城手机版是一个根据我的世界为模板而创造出来的全新
创游编辑器最新版
创游编辑器最新版,一个专门为游戏爱好者们打造游戏编辑软件,可