package ch12;
//substring的用法
public class TestSubstring {
public static void main(String[] args) {
String phoneNbr="05711681688";
System.out.println(phoneNbr.substring(0,4)+"-"+phoneNbr.substring(4));
}
}
/*String java.lang.String.substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this string. The substring
begins at the specified beginIndex and extends to the character at index
endIndex - 1. Thus the length of the substring is endIndex-beginIndex.
Examples:
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"*/
/*String java.lang.String.substring(int beginIndex)
Returns a new string that is a substring of this string. The substring begins with
the character at the specified index and extends to the end of this string.
Examples:
"unhappy".substring(2) returns "happy"
"Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)*/
分享到:
相关推荐
substring用法简介
oracle中 substring函数的使用
在操作sqlserver时候用到了substring函数 SUBSTRING ( expression, start, length ) 参数 expression 字符串、二进制字符串、文本、图像、列或包含列的表达式。请勿使用包含聚合函数的表达式。 start 整数或可以隐式...
substring public String substring(int beginIndex) 返回一个新的字符串,它是此字符串的一个子字符串。该子字符串始于指定索引处的字符,一直到此字符串末尾。 例如: "unhappy".substring(2) returns "happy" ...
java 如何使用substring()方法截取子串 java 如何使用substring()方法截取子串
在js中substring和substr都是用来截取字符串的,那么substring和substr之间的具体区别在哪里,有没有区别呢,下面我来给各位详细引用一些实例来介绍这些问题
str=str.substring(int beginIndex);截取掉str从首字母起长度为beginIndex的字符串,将剩余字符串赋值给str; str=str.substring(int beginIndex,int endIndex);截取str中从beginIndex?始至endIndex结束时的...
怎样使用Substring的应用以及对他的用法方法有更深的了解
js中substring和substr两者区别和使用方法.docx
java中substring与substr的用法.pdf
java中substring与substr的用法实用.pdf
java中substring与substr的用法参考.pdf
substring() 方法用于提取字符串中介于两个指定下标之间的字符。 语法 stringObject.substring(start,stop) 返回值 一个新的字符串,该字符串值包含 stringObject 的一个子字符串,其内容是从 start 处到 stop-1 ...
主要介绍了Java substring原理及使用方法实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
substring操作的字符串,开始截取的位置,返回的字符个数,本文通过简单实例给大家介绍了SqlServer数据库中Substring函数的用法,感兴趣的朋友一起看看吧
String可以使用substring方法进行截取字符串有两种,参数可输入一个或者两个: 单参数:public String substring(int beginIndex) ; 双参数:public String substring(int beginIndex, int endIndex) ;String 类...
SQL 中的 substring 函数是用来抓出一个栏位资料中的其中一部分。这个函数的名称在不同的资料库中不完全一样: MySQL: SUBSTR( ), SUBSTRING( ) Oracle: SUBSTR( ) SQL Server: SUBSTRING( ) SQL 中的 substring ...