package new20140415;
/**
* 字符串
* @author x
*
*/
public class Test1 {
/**
* @param args
*/
public static void main(String[] args) {
// 串连接
String str1="hello";
String str2=" world";
String str3=str1+str2;
System.out.println(str3);//hello world
/*子串
*/
//1
String substr1=str3.substring(6);
System.out.println(substr1);//world
//2
String subStr2=str3.substring(0, 5);
//.substring(a,b)总是有b-1个字符
System.out.println(subStr2);
/**
* 编辑串
*/
int nub=str3.length();
System.out.println(nub);//11
char s=str3.charAt(4);
System.out.println(s);//o
/**
* 串相等
*/
boolean b_str=str1.equals("hello");
//判断字符串是否相等不要使用“==”
System.out.println(b_str);//true
//忽略大小写
boolean b_str2=str1.equalsIgnoreCase("Hello");
System.out.println(b_str2);//true
//返回与字符串匹配的开始的第一个位置
int startNub=str3.indexOf(str2);
System.out.println(startNub);//5
//替换
String newStr3=str3.replace("o", "0");
System.out.println(newStr3);
}
}