JavaSE8基础 String endsWith 判断A字符串是否以B字符串作为结束

os :windows7 x64
    jdk:jdk-8u131-windows-x64
    ide:Eclipse Oxygen Release (4.7.0)
    
    
code:

package jizuiku.t02;

public class Demo02 {
	public static void main(String[] args) {
		String s1 = "World Hello";
		String s2 = "hello";
		String s3 = "Hello";
		String s4 = "HellW";

		System.out.println(s1.endsWith(s2));
		System.out.println(s1.endsWith(s3));//"World Hello" 以 "Hello"作为结尾
		System.out.println(s2.endsWith(s1));
		System.out.println(s3.endsWith(s4));
	}
}

result:



Java优秀,值得学习。
学习资源:API手册+Java源码。

时间: 2024-11-05 13:46:58

JavaSE8基础 String endsWith 判断A字符串是否以B字符串作为结束的相关文章

JavaSE8基础 String equalsIgnoreCase 判断两个字符串的内容是否相同 (不区分大小写)

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t02; public class Demo { public static void main(String[] args) { // 判断两个字符串的内容相同吗 不区分大小写 String s1 = "jizuiku"; String s2 = "a

JavaSE8基础 String equals 判断两个字符串的内容是否相同(区分大小写)

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t02; public class Demo { public static void main(String[] args) { // 判断两个字符串的内容相同吗 String s1 = "jizuiku"; String s2 = "abcdef&q

JavaSE8基础 String startsWith 判断A字符串是否以B字符串作为开头

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t02; public class Demo02 { public static void main(String[] args) { String s1 = "Hello World"; String s2 = "hello"; String

JavaSE8基础 String contains 判断于A中能否连续、完全地见到B

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t02; public class Demo02 { public static void main(String[] args) { String s1 = "Javaer Hello World"; String s2 = "hello";

JavaSE8基础 String trim 去除字符串两端的空格

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t02; public class Demo3 { public static void main(String[] args) { String s1 = " h ell wor l d "; //去除字符串两头的空格 System.out.println(s1

JavaSE8基础 String toCharArray 字符串转换成字符数组

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t01; public class Demo02 { public static void main(String[] args) { String str = "JavaSE8你好"; char[] c = str.toCharArray();//字符串转换成字

JavaSE8基础 String getBytes 将不含中文的字符串转换成字节数组

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t01; import java.nio.charset.Charset; public class Demo01 { public static void main(String[] args) { String str = "[email protected]#$&qu

JavaSE8基础 String charAt 返回字符串中指定索引值所对应的一个字符

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t00; public class Demo2 { public static void main(String[] args) { String str = "abc0123456789"; System.out.println(str.charAt(2));/

JavaSE8基础 String indexOf 正向 从指定索引值开始查找 字符在字符串中第一次出现的位置

os :windows7 x64    jdk:jdk-8u131-windows-x64    ide:Eclipse Oxygen Release (4.7.0)        code: package jizuiku.t00; public class Demo4 { public static void main(String[] args) { // 索引值 0123 String str = "abc01234543210cba"; char ch = '0'; Syst