String类的知识点(不断更新)

知识点
1、String类位于java.lang包中,具有丰富的方法
计算字符串的长度、比较字符串、连接字符串、提取字符串
2、数组的length是属性,字符串的length()是方法
3、import java.util.*; 导入java.util包中所有的类

package day20181129;
/**
* 字符串的使用
* @author Administrator
*
*/
public class StringDemo01 {
public static void main(String[] args) {
//字符串常量池
String s1="abc";
String s2="abc";
//==比较对象的内存地址是否相同
System.out.println(s1==s2);//true
//使用new关键字创建字符串对象
String s3=new String("abc");
String s4=s3;
System.out.println(s3==s4);//true
System.out.println(s1==s3);//false

}
}

猜你喜欢

转载自www.cnblogs.com/SUN99bk/p/10041040.html