String
Yang__Sang
没事别升级jdk
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
字符串部分常用操作
字符串包含关系 String a ="hello world"; String b ="world"; .contains()b是a的字符串字串/子字符串 a就包含b String a="hello world"; String b="world"; System.out.println(a.contains(b)); 结果true 证明包含 String a="hello world"; String b="worldd"; System.out.pri原创 2021-01-19 21:42:49 · 253 阅读 · 0 评论 -
compareTo()方法与compareToIgnore()方法
比较字符串的大小 String a="hello"; String b="hallo"; //compareTo返回的是一个int //a比b小,返回<0的数 //a比b大,返回>0的数 //相等返回0 int result=a.compareTo(b); System.out.println(result); 结果是4 结果是两个不一样的位数的ascall值的差 ...原创 2021-01-19 16:02:36 · 435 阅读 · 0 评论 -
String的intern()方法
public class Test20210118 { public static void main(String[] args) { String a ="qazwsxedc"; String b =new String("qazwsxedc").intern(); System.out.println(a==b); } } 结果是true public class Test20210118 { public static vo原创 2021-01-18 11:06:59 · 164 阅读 · 0 评论 -
String的equals方法与.equalsIgnoreCase()
public static void login() { String pasword = "123456"; System.out.println("请输入密码:"); Scanner scanner = new Scanner(System.in); int i=0; while ( i < 5) { String input = scanner.next(); if (原创 2020-12-27 11:22:14 · 217 阅读 · 0 评论
分享