码迷,mamicode.com
首页 > 其他好文 > 详细

Map练习错误

时间:2014-11-25 00:15:26      阅读:115      评论:0      收藏:0      [点我收藏+]

标签:style   io   ar   color   sp   for   strong   on   div   

 

private Student findStuByNumber(String number) {
      
      Student student=null ;
      for(Student stu: list) {
          if(stu .getNumber()!=null&& stu.getNumber().equals( number)) {
                   student=stu;
               return student ;
               break;
          }
      }
       //错误,return null;
            return student;
   }
 
注意//return null;   不管循环结束或者没结束,都返回null.   无法返回 循环里边的stu;

Map练习错误

标签:style   io   ar   color   sp   for   strong   on   div   

原文地址:http://www.cnblogs.com/landynn/p/4119883.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!