startsWith和endsWith判断字符串是否是以给定的内容开始或结束的
1 /** 2 * boolean startsWith(String str) 3 * boolean endsWith(String str) 4 * 判断字符串是否是以给定的内容开始或结束的 5 * 6 */ 7 public class StartsWithDemo { 8 public static void main(String[] args) { 9 String line = "www.baidu.com"; 10 boolean starts = line.startsWith("www."); 11 System.out.println("start:"+starts); 12 13 boolean ends = line.endsWith(".com"); 14 System.out.println("end:"+ends); 15 } 16 }

浙公网安备 33010602011771号