package day3;
import java.util.Scanner;
public class spring{
public static void main(String[] args) {
String str1 = "Apple";
String str2 = "banana";
System.out.println(str1.compareTo(str2));//返回小于0的整数,str1比str2小
System.out.println(str2.compareTo(str1));//返回大于0的整数,str2比str1大
System.out.println(str2.compareTo("banana"));//返回0, 相等
System.out.println(str2.compareTo("Banana"));
System.out.println(str2.compareToIgnoreCase("Banana"));//不区分大小写返回0
String token = "Bear-eyJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiJ9.eyJwaG9uZSI6IjEzNTAwMDAxMTExIiwiaWQiOjJ9.gjbMpA1t6eor6iC66II21wkfayXiMXL_8IPHM4Yc728";
System.out.println(token.startsWith("Bear-")); //token字符串是否以特定前缀Bear-开头
System.out.println(token.endsWith("token")); //false,是否以token结尾
System.out.println(token.contains("eyJwaG"));//true,字符串中是否有该字符
String email = "zhangrui@uestc.edu.cn";
System.out.println(email.indexOf("@"));
System.out.println(email.indexOf("."));//返回第一次出现.的索引位置
System.out.println(email.indexOf("peppa"));//在email字符串中找不到peppa子串,返回-1
System.out.println(email.lastIndexOf("."));//最后一次出现.的索引位置
//字符串截取
//substring(index):从指定的索引位置截取到字符串的结尾
if(email.indexOf("@") != -1) {
System.out.println("邮箱域名:" + email.substring(email.indexOf("@") + 1));
//substring(begin,end):从begin索引位置开始截取,截取到end索引位置(不包含end,长度为:end-being)
System.out.println("用户名:" + email.substring(0, email.indexOf("@")));
int number = 2000;
String srt = number + "";
System.out.println(srt.length());//输出字符串长度
}
}
}