(1)今天做了什么; (2)明天准备做什么? (3)遇到的问题,如何解决?
今天继续学习菜鸟教程java字符串实例
5.字符串反转——reverse方法
public class Main { public static void main(String[] args) { String string="runoob"; String reverse = new StringBuffer(string).reverse().toString(); System.out.println("字符串反转前:"+string); System.out.println("字符串反转后:"+reverse); } }
6.字符串搜索——indexOf方法
public static void main(String[] args) { // indexOf() 方法在字符串中查找子字符串出现的位置,如果存在返回字符串出现的位置(第一位为0),如果不存在返回 -1; String str = "hello world"; int intIndex = str.indexOf("llo"); if(intIndex == -1) System.out.println("没有找到该字符串"); else System.out.println("该字符串位置为:" + intIndex); }
7.字符串分割——split方法