摘要: max() 1 public static int max(int a, int b) { 2 return Math.max(a, b); 3 } 4 5 6 /** 7 *Math 的max方法 8 */ 9 public static int max(int a, int b) { 10 re 阅读全文
posted @ 2019-03-19 00:02 damon11 阅读(124) 评论(0) 推荐(0) 编辑
摘要: Object类有以下几个方法 equals() 1 /** 2 * Indicates whether some other object is "equal to" this one. 3 * <p> 4 * The {@code equals} method implements an equi 阅读全文
posted @ 2019-03-18 22:25 damon11 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 对于对象,== 与 != 比较的是引用;对于基本类型,比较的是内容。 包装类都是引用数据类型。 非基本数据类型的对象,比较内容时,可以使用对应的equals()。如果在该类中,没有重写Object的equals方法,那么会默认比较引用,就不可能出现我们希望的 行为。 如下边代码: 如果在Value类 阅读全文
posted @ 2019-03-05 23:31 damon11 阅读(149) 评论(0) 推荐(0) 编辑
摘要: String类有两个私有的变量,字符数组value,和整型变量hash(默认为0)。 String的构造器会对value进行赋值,有时也对hash进行赋值。 1 /** 2 * Initializes a newly created {@code String} object so that it 阅读全文
posted @ 2019-03-05 22:20 damon11 阅读(166) 评论(0) 推荐(0) 编辑