????????????????x.equals(y)==false???x.hashCode()!=y.hashCode()?????????????????????????????????????????????????
????hashCode()??????????????return 0????????????????????????????HashMap??Щ????????еú?????
?????ο???java.lang.Object.hashCode()??
???????compareTo()
????class Person implements Comparable<Person>{
????String firstName;
????String lastName;
????int birthdate;
????//Compare by firstName??break ties by lastName??finally break ties by birthdate
????public int compareTo(Person other){
????if(firstName.compareTo(other.firstName)!=0)
????return firstName.compareTo(other.firstName);
????else if(lastName.compareTo(other.lastName)!=0)
????return lastName.compareTo(other.lastName);
????else if(birthdate<other.birthdate)
????return-1;
????else if(birthdate>other.birthdate)
????return 1;
????else
????return 0;
????}
????}
??????????????汾Comparable???????????????Comparable?????????????????????????????????鷳??
?????????????????????????/??/????????????С???????
????Comparator.compare()???????????????
?????ο???java.lang.Comparable??
???????clone()
????class Values implements Cloneable{
????String abc;
????double foo;
????int[]bars;
????Date hired;
????public Values clone(){
????try{
????Values result=(Values)super.clone();
????result.bars=result.bars.clone();
????result.hired=result.hired.clone();
????return result;
????}catch(CloneNotSupportedException e){//Impossible
????throw new AssertionError(e);
????}
????}
????}
???????super.clone()??Object???????μ????
???????????????????????????????????????????????String??BigInteger???????????
????????????е???????????????????飩???????????deep copy????
?????????Cloneable????clone()????????????CloneNotSupportedException??????????????????????????????????ò????????unchecked exception?????????
?????????Object.clone()????????????????clone()??????????????????
?????ο???java.lang.Object.clone()??java.lang.Cloneable()??
???????StringBuilder??StringBuffer
????//join(["a"??"b"??"c"])->"a and b and c"
????String join(List<String>strs){
????StringBuilder sb=new StringBuilder();
????boolean first=true;
????for(String s:strs){
????if(first)first=false;
????else sb.append("and");
????sb.append(s);
????}
????return sb.toString();
????}
???????????????????????????????s+=item????????????Ч????O(n^2)??
???????StringBuilder????StringBuffer??????????append()???????????????toString()???????????????????????????
???????????StringBuilder???????????StringBuffer?????з???????????????????????????????????
?????ο?java.lang.StringBuilder??java.lang.StringBuffer??
?????????????Χ??????????
????Random rand=new Random();
????//Between 1 and 6??inclusive
????int diceRoll(){
????return rand.nextInt(6)+1;
????}
???????????Java API??????????????????Χ??????????
??????????????Math.abs(rand.nextInt())%n??Щ????????÷?????????????????????????????????п?????????????統rand.nextInt()==Integer.MIN_VALUE???????
?????ο???java.util.Random.nextInt(int)??
???????Iterator.remove()
????void filter(List<String>list){
????for(Iterator<String>iter=list.iterator();iter.hasNext();){
????String item=iter.next();
????if(...)
????iter.remove();
????}
????}
????remove()??????????next()????????????????????????????????remove()??????
?????ο???java.util.Iterator.remove()??
????????????
????String reverse(String s){
????return new StringBuilder(s).reverse().toString();
????}
?????????????????ü???Java?????
?????ο???java.lang.StringBuilder.reverse()??