substring(int,int)就是取子串.第一个参数是子串的起始位置,从0开始,第二个参数是子串的长度.所以ss.substring(0,5)的结果是从0开始,长度为5的子串,即12345.其他的类似.
解决方案 »
- 高分求救查询树形结构中某节点逆展开所有路径问题
- emma统计覆盖率时报错:RPC failure while executing [coverage.get]
- DecimalFormat取值问题
- 大家能帮帮我吗?谢谢了
- !!!操作数据库是出现:将截断字符串或二进制数据?帮忙!!!!!!!!!!!!
- 问个关于java转换ASCII编码的问题
- 这样写那里不对
- 求高手帮我解释一下这道题,感激不尽
- 金蝶BOS开发的前景
- 点击JB中的Database组件的conection属性的时候(准备连接sql server),怎么会没有反应?
- JAVA新手,关于BoxLayout的问题。
- 求救:怎么将已读入的流文件以字节形式取出
0 1 2 3 4 5 6 7
1 2 3 4 5 6 7
就是说你的1-7从0到7这样分配,这样应该很好解释了把
substring(int beginIndex, int endIndex)
Returns a new string that is a substring of this string.
两个参数beginindex和endindex表示要取的子串的下标范围,包括beginindex,不包括endindex。
System.out.println(ss.substring(2,3));
//这个输出是 3System.out.println(ss.substring(3,3));
//这个输出是空,难道不奇怪吗
beginIndex 从0开始计数,endIndex 为什么从1开始计数?
//这个输出是空,难道不奇怪吗
beginIndex 从0开始计数,endIndex 为什么从1开始计数?
--------------------------------------------------------------------
有什么奇怪,你取beginIndex是3,但endIndex 也是3,正因为endIndex是取前一个所以不能取3.这很合理呀