⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findsubstring.java

📁 编程之道--java程序设计入门源代码
💻 JAVA
字号:
/**
 * 查找特定的子串
 */
public class FindSubstring
{
	public static void main(String[] args)
	{
		String str = "welcome the boy.";
		System.out.println("Find the substring boy occurrence:" + str.indexOf("boy"));//查找子串
		System.out.println("Find the substring by occurrence:" + str.indexOf("by"));//查找子串
		System.out.println("Find the char t occurrence:" + str.indexOf('t'));//查找特定的字符	
		System.out.println("Test the string begin with wel.:" + str.startsWith("wel"));// 是否以"wel"开始
		System.out.println("Test the string end with boy.:" + str.endsWith("boy"));// 是否以"boy"结束

	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -