//我们的写代码方式
        if(subdirs!=null&&subdirs.length>0){
            for (int i = 0; i <subdirs.length ; i++) {
                if(i!=subdirs.length-1){
                    str = str + subdirs[i]+"/";
                }else{
                    str  = str+ subdirs[i];
                }
            }
        }
        System.out.println("str:"+str);


        //google 工程师的写代码方式
        Iterable iterable= (Iterable) Arrays.asList(subdirs);
        Iterator iterator=  iterable.iterator();
        StringBuffer xx=new StringBuffer();
        xx.append(iterator.next());
        while (iterator.hasNext()){
            xx.append("/");
            xx.append(iterator.next());
        }
        System.out.println("xx:"+xx);

        StringBuffer yyy=new StringBuffer();
        iterator=  iterable.iterator();
        while (iterator.hasNext()){
            yyy.append(iterator.next());
            if (iterator.hasNext()){
                yyy.append("/");
            }
        }
        System.out.println("yyy:"+yyy);
0喜欢 - 0个评论
头像

代码人

  • 粉丝 0
  • 关注 0
  • 好友 0
关注我

关于我

Education

B.S. in Computer Science from the University of Tennessee at Knoxville


Location

Malibu, California


个人介绍