摘要: 1.变量类型转换 (1)int() | int() | 将一个数值或字符串转换成整数,可以指定进制 | | | | print(int(10+3)) #13 print(int("45")) #45 print(int('0011',2)) #3 将二进制数0011转化为十进制数3 print(in 阅读全文
posted @ 2022-09-15 19:40 植树chen 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 1.Object类中的equals()和toString() (1)Object类中定义的equals()和==的作用是相同的:比较两个对象的地址值是否相同,只能用于引用数据类型 public boolean equals(Object obj) { return (this == obj); } 阅读全文
posted @ 2022-09-15 17:08 植树chen 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 1.Object类源码 点击查看Object类源码-带注释 package java.lang; /** * Class {@code Object} is the root of the class hierarchy. * Every class has {@code Object} as a 阅读全文
posted @ 2022-09-15 16:39 植树chen 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1.基本数据类型和引用数据类型转换比较 (1)基本数据类型转换 ① 自动类型转换:小->大 long g = 20; double d = 12.0f; ② 强制类型转换:大->小 float f = (float)12.0; int a = (int)1200L; (2)引用类型转换 ① 子类-> 阅读全文
posted @ 2022-09-15 08:56 植树chen 阅读(70) 评论(0) 推荐(0) 编辑