//删除roomSchedule :cry:
List<TRoomSchedule> roomScheduleList = IAS.getTRoomScheduleByAppointId(open.getAppointId(),"A");
if(roomScheduleList != null && roomScheduleList.size() > 0){
TRoomSchedule roomSchedule = roomScheduleList.get(0);
ICS.delete(roomSchedule);
}
今天编写程序,遇到list index out of bounds的异常,原因出在roomScheduleList.get(0);这句话,百度了一下,说的很贴切,和大家分享:
引用
举个形象的例子,我有一个空着的水杯(list),而你没有,那你是null,我的size为0。你想装水需要去买个水杯(new ArrayList();),我就可以直接装水(list.add(水))。你要是没有杯子直接倒水,水就流出去啦(空指针异常)。所以用做判断的时候经常连用 list!=null && list.size()!=0 。
分享到:
相关推荐
list.size()与list==null的区别 两者的区别是显而易见的,下面这两段就能显示两者差别: List list1 = new ArrayList(); System.out.println(list1.size());//0 List list2 = null; System.out.println(list2.size()...
if(values==null || values.size()==0) return; for (Iterator[]> iterator = values.iterator(); iterator.hasNext();) { String[] value = iterator.next(); XWPFTableRow newRow = new XWPFTableRow(ctRow,...
= null && list.size()>0 ? list.get(0) : null; } //根据编号查询 public User getUserByUserno(int userno){ String sql = "select * from userinfo where userno = ?"; List<User> list = ...
size = 0; } // 添加元素到链表尾部 public void add(int value) { Node<Integer> newNode = new Node(value); if (head == null) { head = newNode; } else { Node<Integer> current = head; while ...
List<books> books = new BooksImpl().Select(pagebean);//分页显示所有的数据 if(books!=null){ int count = new BooksImpl().SelectCount();//查出总共有多少条数据 int pageCount= pagebean....
return list.size(); } @Override public Object getItem(int position) { // TODO Auto-generated method stub return list.get(position); } @Override public long getItemId(int position) { // ...
可以查看上线人数 监听器 servlet 登出时,session失效。...=null&&vector.size()>0){//如果对象数组不为空,大小 for(int i=0;i<vector.size();i++){ out.println(vector.elementAt(i));//打印出用户名来 } } %>
= null && pred.size() > 0) { List pred_tasksList = new ArrayList(); for (int x = 0; x < pred.size(); x++) { Relation r = (Relation) pred.get(x); String rId = String....
用户聊天界面=new ChatArea("",listTable,width,height-(h+5)); 用户聊天界面.setVisible(false); 提示条=new Label("正在连接到服务器,请稍等...",Label.CENTER); 提示条.setForeground(Color.red); north=new...
<input type="text" name="name" size="15"> File: <input type="file" name="myfile"> <input type="submit" name="submit" value="Commit"> ``` **JSP 处理**: ```jsp ...
List, Object>> testList = (List, Object>>) sqlMap.queryForList("getTest", null); Map, String> result = new HashMap(); for (int i = 0; i < testList.size(); i++) { Map, Object> tmp = testList.get(i)...
// .set_size = NULL, // }, //// /* 720p */ //// { //// .width = HD720_WIDTH, //// .height = HD720_HEIGHT, //// .hoffset = 0, //// .voffset = 0, //// .regs = Gc2015_sensor_hd720_regs, //// .regs_...
=null&&header.size()>0) { for (String key : header.keySet()) { httpost.setHeader(key,header.get(key)); } } List <NameValuePair> nvps = new ArrayList (); for (String keyItem : params...
int size = list.size(); for (int i = 1; i < size; i++) { TreeNode prev = list.get(i - 1), curr = list.get(i); prev.left = null; prev.right = curr; } } public void preorderTraversal(TreeNode ...
if(list == null && list.size() ==0){ return null; } //获取服务注册列表的个数 int size = list.size(); int index = requestCount % size; requestCount++; return list.get(index).getUri()....
List list = null; try { setDateFormat2Java(); JSONArray array = JSONArray.fromObject(jsonString); list = new ArrayList(); for (Iterator iter = array.iterator(); iter.hasNext();) { ...
= null && mContents.size() != 0) { if (mContents.size() == 1) { setContent(mContents.get(0)); } else { for (int i = 0; i < mContents.size(); i++) { View view = mInflater.inflate(R.layout.diaolog_...
pb[i].Size = new Size(Picsize, Picsize); pb[i].Location = new Point((i % gzs) * Picsize, (i / gzs) * Picsize); pb[i].BorderStyle = BorderStyle.FixedSingle; pb[i].Name = a[i].ToString(); pb[i]....
if (fileList == null || fileList.size() == 0) { out.println("请选择上传文件<p />"); out.println("<a href=\"upload2.jsp\" target=\"_top\">返回</a>"); return; } // 得到所有上传的文件 Iterator fileItr = ...
list.insertAt(0, 0); list.printList(); // 输出:0 1 2 3 list.remove(2); list.printList(); // 输出:0 1 3 System.out.println("链表长度:" + list.size()); // 输出:3 } ``` 通过这个例子,你不仅学会...