package lei; public class TestStringpool { public static void main(String[] args) { String s="java"; String s1="java"; //是否相等 if(s==s1){ System.out.println("是同一个对象"); if(s.equals(s1)){ System.out.println("内容相等"); } } } }
package lei; public class TestString2 { public static void main(String[] args) { //split String s="刘备,张飞,关羽,曹操,马云"; String[]names=s.split(","); for(String n:names){ System.out.println(n); } String str=" 爱情吧不是你想买,想买就能买Abc "; System.out.println(str.isEmpty()); System.out.println(str.indexOf("买",str.indexOf(‘买‘)+1)); System.out.println(str.toUpperCase()); System.out.println(str.trim()); String s1="matlab"; String s2="MATLAB"; System.out.println(s1.equalsIgnoreCase(s2)); } }
时间: 2024-11-01 18:34:07