package string;
import org.junit.Test;
import java.sql.SQLOutput;
public class Stringtext {
@Test
public void _string(){
//substring()方法:对字符串进行切片
String greeting="hello";
String s=greeting.substring(0,3);
System.out.println(s);
//拼接
String expletive="Expletive";
String PG13="delect";
String massage=expletive+PG13;
System.out.println(massage);
System.out.println("the answer is " + massage);
String all=String.join("/","S","M","L","Xl");
System.out.println(all);
//检查字符串是否相等
System.out.println("hello".equals(greeting)+" "+"Hello".equalsIgnoreCase("hello"));
System.out.println(greeting.compareTo("hello")+" "+greeting.compareToIgnoreCase("Hello"));
System.out.println("hello".substring(0,3));
System.out.println("hello".substring(0,3)=="hel"?true:false);
//空串与null
//String API
//构造字符串
char ch=' ';
StringBuilder builder=new StringBuilder();
builder.append("hello");
builder.append(ch);
builder.append("word");
String completedString1=builder.toString();
System.out.println(completedString1);
builder.setCharAt(0,'H');
System.out.println(builder.toString());
builder.insert(1,'!');
System.out.println(builder.toString());
builder.delete(1,2);
System.out.println(builder.toString());
}
}