易截截图软件、单文件、免安装、纯绿色、仅160KB

JAVA split 用法

java.lang.string.split
split 方法
将一个字符串分割为子字符串,然后将结果作为字符串数组返回。
stringObj.split([separator,[limit]])
stringObj
必选项。要被分解的 String 对象或文字。该对象不会被 split 方法修改。
separator
可选项。字符串或 正则表达式 对象,它标识了分隔字符串时使用的是一个还是多个字符。如果忽
略该选项,返回包含整个字符串的单一元素数组。
limit
可选项。该值用来限制返回数组中的元素个数。
说明:
split 方法的结果是一个字符串数组,在 stingObj 中每个出现 separator 的位置都要进行分解
。separator 不作为任何数组元素的部分返回。
示例1:
public class SplitDemo {
   
     public static String[] ss = new String[20];
     public SplitDemo() {
         String s = "The rain in Spain falls mainly in the plain.";
         // 在每个空格字符处进行分解。
         ss = s.split(" ");
     }
     public static void main(String[] args) {
         SplitDemo demo = new SplitDemo();
         for (int i = 0; i < ss.length; i++)
             System.out.println(ss[i]);
     }
}
程序结果:
The
rain
in
Spain
falls
mainly
in
the
plain.
示例2:
public class SplitDemo {
     public static String[] ss = new String[20];
     public SplitDemo() {
         String s = "The rain in Spain falls mainly in the plain.";
         // 在每个空格字符处进行分解。
         ss = s.split(" ", 2);
     }
     public static void main(String[] args) {
       


相关文档:

sql 2005 存储过程分页 java 代码

 create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',         
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列 ......

传智播客的JAVA SE高级视频3 GUI 自学笔记

GUI:Graphical User Interface
     JDK中:AWT和Swing
    GUI组件分为两大类:基本组件和容器。
    基本组件继承自java.awt.Component或其子类
    容器继承自java.awt.Container或其子类
    程序GUI部分由AWT线程管理。
事件 ......

Java 过滤字符串(用模式匹配实现)

//Number 11   过滤字符串中的非数字字符
import java.util.regex.*;
import java.util.Scanner;
public class GuoLv{
    public static void main(String args[]){
       Scanner    reader    = new Scanner(System.in);
  ......

java解析XML的四种方法

XML现在已经成为一种通用的数据交换格式,它的平台无关性,语言无关性,系统无关性,给数据集成与交互带来了极大的方便。对于XML本身的语法知识与技术细节,需要阅读相关的技术文献,这里面包括的内容有DOM(Document Object Model),DTD(Document Type Definition),SAX(Simple API for XML),XSD(Xml Schema Definition),XSLT(Exten ......

线程安全的Singleton模式的Java实现

public class Factory {
private static Factory factory;
private static Object classLock=Factory.class;
   private Factory(){}
   public static Factory getFactory(){
      synchronized(classLock){
          ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号