javasubstringindexof() lastindexof()

str=str.substring(int beginIndex);截取掉str从首字母起长度为beginIndex的字符串,将剩余字符串赋值给str;

str=str.substring(int beginIndex,int endIndex);截取str中从beginIndex开始至endIndex结束时的字符串,并将其赋值给str;

indexOf

public int indexOf(Object o,                      int index)

返回此向量中第一次出现的指定元素的索引,从 index 处正向搜索,如果未找到该元素,则返回 -1。


lastIndexOf

public int lastIndexOf(Object o)

返回此向量中最后一次出现的指定元素的索引;如果此向量不包含该元素,则返回 -1。


以下是一段演示程序:

public class Test{

public static void main(String agrs[]){

String str="tao.jpg";

System.out.println("点的索引:"+str.lastIndexOf("."));

str=str.substring(str.lastIndexOf("."));

System.out.println("陶相山陶相山陶相山:"+str);

}}

运行结果是:点的索引:3

陶相山陶相山陶相山:.jpg

最新文章

  1. LeetCode:Word Ladder I II
  2. 认识基本的mfc控件
  3. md5的C++实现
  4. SimpleDateFormate的使用
  5. win2008主机IIS7.x 关于web.config设置301重定向
  6. bootstrap学习笔记<七>(图标,图像)
  7. 【转】如何使用PhoneGap打包Web App
  8. notebook笔记
  9. Umbraco(7)-The Navigation Menu And A Parent Page with Infinite Children
  10. posix thread条件变量
  11. Git-it:一个学习Git和Github的教程(软件)
  12. Yii PHP 框架分析(二)
  13. ERROR: The node /hbase is not in ZooKeeper. It should have been written by the master. Check the value configured in 'zookeeper.znode.parent'. There could be a mismatch with the one configured in the
  14. angr进阶(5)内存操作
  15. Html5: Drawing with text
  16. python 分享一个通过 (key1.key2.key3) 形式获取嵌套字典值的方法
  17. DEM山体阴影原理以及算法具体解释
  18. freeswitch 获取当前网关通道数
  19. CXF develop Webserice Tuturial
  20. Android控件第3类——AdapterView

热门文章

  1. cnb
  2. Shape 与 InlineShape 的区别
  3. Memcached 两款.NET客户端的郁闷事儿
  4. wpa_supplicant 与iwpriv工具配置WIFI的命令
  5. HDU 4135 Co-prime
  6. HW4.5
  7. 尝试获取TextBox_TextChanged事件订阅列表过程
  8. hdoj 3549 Flow Problem【网络流最大流入门】
  9. DATASNAP复杂中间件的一些处理方法
  10. EGOImageView的使用方法及注意事项