20200928冯强
学习总结:
1.String类
1.1charAt
 返回指定的字符索引 如:
String str ="Hello";
str.charAt(1);  //e
str.charAt(1,3) //el
1.2compareTo
比较两个字符串 返回0代表一样
 返回负数代表调用者的字符Unicode码小
 返回正数代表调用者的字符Unicode码大
1.3toString
返回字符串本身 若为地址直接打印值
1.4subString
截取字符串
String str = new String ("abc");
String str2 =str.subString(1,3); //值为bc
2.Object
Object是所有没有extends类的直接父类
2.1getClass();
获取class对象 反射时用
2.2wait notify
线程使用
2.3toString
返回地址
2.4equals
@Override
public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    Demo other = (Demo) obj;
    if (age == null) {
        if (other.age != null)
            return false;
    } else if (!age.equals(other.age))
        return false;
    if (name == null) {
        if (other.name != null)
            return false;
    } else if (!name.equals(other.name))
        return false;
    return true;
}//重写equals方法
2.5hashcode
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((age == null) ? 0 : age.hashCode());
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }//重写hashcode
3包装类
3.1基本数据类型的包装类
int -Integer byte - Byte short - Short long - Long
float - Float double - Double char - Character boolean - Boolean
3.2自动装箱/拆箱
运算时基本数据类型加减 包装类无法计算
学习心得
String str = "123";
String str1 =new String (str+"d");
String str2 == "abcd";
System.out.println(str1==str2)//false
//str1引用的是str 和字面量d的地址 不会再常量池创建空间
    
					点赞
				
    

评论留言