zoukankan      html  css  js  c++  java
  • split(":")[0].substring(1)

    java中拆分字符中的split(":")[0].substring(1)是什么意思啊,尤其[0] 可以解释一下吗?

    比如你有一个字符串 "111:222:333" ,首先,split 把 111,222,333分别放到数组。
    [0] 就是取第一个数, 111 。 subString(1)就是从第2个位置截取 111,结果 11 。

    String.SubString(int   index,int   length)
      index:开始位置,从0开始    
      length:你要取的子字符串的长度

    string myString = "Hello Word!";
    //Substring()在C#中有两个重载函数
    //分别如下示例
    string subString1 = myString.Substring(0);

    //如果传入参数为一个长整, 且大于等于0,
    //则以这个长整的位置为起始,
    //截取之后余下所有作为字串.
    //如若传入值小于0,
    //系统会抛出ArgumentOutOfRange异常
    //表明参数范围出界

    string subString2 = myString.Substring(0, 5);

    //如果传入了两个长整参数,
    //前一个为参数子串在原串的起始位置
    //后一个参数为子串的长度
    //如不合条件同样出现上述异常
    Console.WriteLine(subString1);  Hello Word!
    Console.WriteLine(subString2);  Hello

    传入一个参数的时候:假如一个参数为2,就是剩余的字串从位置2开始到结尾
    传入二个参数的时候,加入是(2,3) ,从位置2开始截取3个长度的子串

  • 相关阅读:
    Git 简要教程
    SDK更新失败问题解决
    常用安卓操作
    MongoDB本地安装与启用(windows 7/10)
    windows 快捷键收集
    windows 常用命令
    Lambda Expression Introduction
    对 load_breast_cancer 进行 SVM 分类
    Support Vector Machine
    使用 ID3 对 Titanic 进行决策树分类
  • 原文地址:https://www.cnblogs.com/ZkbFighting/p/8038087.html
Copyright © 2011-2022 走看看