sjcp杂记

//NumberFormat is abstract. You must use the getInstance method to get a NumberFormat instance
// Calendar and DateFormat instances are created using getXxx() factory methods.
// the class Scanner default separator is a blank NOT a comma.
// The overriding talk() method has a weaker access modifier. so compile failed
//Multiple threads can be created using the same Runnable object, but a given thread can be started only once.if have more ,will compile but throws runtimeExcpeption
// The ^ operator returns true when exactly one operand is true.
// int method(int ... x)    int method(int x)  The methods are different signature, will overload
// An object can be collected even if it has a valid reference, if no live thread has access to the object
//objects reside in the heap; and the finalize method can send an object reference to another object, thereby an object's finalize method runs to completion, the object will not always be garbage collected.
//An enum may NOT be declared in a method
//If the JVM has a choice, it will select a method without varargs(变长参数...) before selecting a method with varargs.
//By default the readPassword() method does not echo the user's input.
//Only the Scanner class can use a stream as a source.
// because four different threads are started and each must have a unique Id.
//both classes have references to instances of each other: tightly coupled, only one references to another is loosely coupled
//It is legal to re-implement a private method in a sub-class, but Page does not know about Book's read method
// SortedMaps are abstract, Hashtable does NOT implement HashMap, and ArrayList is not a map
//The TreeSet is sorted alphabetically.
// If either operand is a String, the + operator concatenates.
//When enums are equal, both .equals and == always return true
// TreeSet<Animal> t = new TreeSet<Animal>(); TreeSet s = new TreeSet , Only the s and t can pass to  a method  (set<animal> a),
//The headMap() method returns the portion of the map whose keys are less than the key sent to it.
//The asList() method creates a fixed-size list that is backed by the array, so no additions are possible.
//Since Stuff implements Comparator, it must implement a compare method.
//Since Stuff implements Comparable, it must implement a compareTo method.
//x.X.doX();   x.X myX = new x.X(); myX.doX();  Fully qualified names require in a file with no import statements.
//在继承重写父类方法的时候,如果父类是void ,重写必须是void, 不是void则要求返回类型比父类等或小   。 权限必须相等或变大
//父类的final方法不能被子类覆盖
//Exception 和 Error 是继承于  Throwable 类  ,Exception 必需要catch , 而error不是,只是抛出来。
//Cannot use super in a static context
//implements is "is a" relationship
//子类 sub  foo(int i) 没有重写父类base  foo(int ... i) 那么 父类引用指向子类对象时   Base  base = new sub(); base.foo()指向的是父类的foo,也就是说重载
//Two different array objects can never be ==, even if their contents are the same
//HashSet内部使用HashMap管理对象,添加对象到HashSet时,是将对象作为内部HashMap的key进行处理,若发现已存在hashCode相同且equals比较结果为true的对象,就认为该key已经存在,返回HashMap中的旧对象回来,而多个Person对象有不同的hashCode,因此全可以被加入到HashSet
//对于两个对象,如果hashCode一样, 没有重写equals ,还是允许插入。插入在冲突的下一个位置
//Integer等封装类都继承自 java.lang.Number
//equals比较为真的两个对象,必须要有相同的HashCode。这是Java规范约定的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值