package cn.yyhl.day11;
/*
字符串的截取方法:
public String substring(int index):截取从参数位置一直到字符串末尾,返回新字符串。
public String substring(int begin, int end):截取从begin开始,一直到end结束,中间的字符串。
备注:[begin,end),包含左边,不包含右边。
*/
public class String05Substring {
public static void main(String[] args) {
String str = "helloworld";
String str1 = str.substring(5);
System.out.println(str);//helloworld 原封不动
System.out.println(str1);//world,新字符串
System.out.println("====================");
String str2 = str.substring(4,7);
System.out.println(str);//helloworld 原封不动
System.out.println(str2);//owo 新字符串
System.out.println("====================");
//下面这种写法,字符串内容仍是没有改变的,下面有两个字符串:"Hello" "Java"
//strA当中保存的是地址值,本来地址是Hello的0x666,后来变成了Java的0x999
String strA = "Hello";
System.out.println(strA);//Hello
strA = "Java";
System.out.println(strA);//Java
}
}