(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方法

相关文章:

  • 2022-03-09
  • 2021-10-06
  • 2021-07-03
  • 2021-11-04
  • 2022-12-23
  • 2021-07-29
猜你喜欢
  • 2021-12-03
  • 2021-09-27
  • 2021-09-07
  • 2021-12-10
  • 2021-12-01
  • 2021-09-26
  • 2021-05-24
相关资源
相似解决方案