Energy of Love  
日历
<2011年8月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910
统计
  • 随笔 - 70
  • 文章 - 0
  • 评论 - 80
  • 引用 - 0

导航

常用链接

留言簿

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 
String[] userData = "1######".split("#");
System.out.println(userData.length);
输出:userData.length = 1
该方法的作用就像是使用给定的表达式和限制参数 0 来调用两参数 split 方法。因此,结果数组中不包括结尾空字符串。 

Java代码  收藏代码
  1. // Construct result  
  2.         int resultSize = matchList.size();  
  3.         if (limit == 0)  
  4.             while (resultSize > 0 && matchList.get(resultSize-1).equals(""))  
  5.                 resultSize--;  
  6.         String[] result = new String[resultSize];  
  7.         return matchList.subList(0, resultSize).toArray(result);  



split方法是调用Pattern的split实现的,看上面代码中的 
while (resultSize > 0 && matchList.get(resultSize-1).equals("")) 
                resultSize--; 
可见。字符串末尾的空字符串将从匹配结果中去除 
posted on 2011-08-25 15:37 不高兴 阅读(1125) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航:
 
 
Copyright © 不高兴 Powered by: 博客园 模板提供:沪江博客