passer1991

2012年10月5日

截取字符串,只截取前N个字节的字符

摘要: publicvoidcutString(Stringstr,intn){Stringtemp;intcount=0;for(inti=0;i<str.length();i++){temp=str.charAt(i)+"";count+=temp.getBytes().length;if(count>n)break;System.out.print(temp);}}@TestpublicvoidtestString(){cutString("我ABC好的sfd",7);} 阅读全文

posted @ 2012-10-05 15:52 passer1991 阅读(406) 评论(0) 推荐(0) 编辑

插入排序

摘要: publicvoidinsertSort(List<Integer>list){if(list.size()<2)return;for(inti=1;i<list.size();i++){inttemp=list.get(i);intbefore=list.get(i-1);if(temp>before)continue;for(intj=0;j<i;j++){if(list.get(j)>temp){list.remove(i);list.add(j,temp);break;}}}}@TestpublicvoidtestInsertSort(){Li 阅读全文

posted @ 2012-10-05 15:28 passer1991 阅读(130) 评论(0) 推荐(0) 编辑

导航