Почему я не люблю писать комментарии

Apr 08, 2010 10:39

Код из java.util.AbstractList:


copy to clipboardподсветка кода
  1. /**  
  2.  * Compares the specified object with this list for equality.  Returns  
  3.  * {@code true} if and only if the specified object is also a list, both  
  4.  * lists have the same size, and all corresponding pairs of elements in  
  5.  * the two lists are equal.  (Two elements {@code e1} and  
  6.  * {@code e2} are equal if {@code (e1==null ? e2==null :  
  7.  * e1.equals(e2))}.)  In other words, two lists are defined to be  
  8.  * equal if they contain the same elements in the same order.
      
  9.  *  
  10.  * This implementation first checks if the specified object is this  
  11.  * list. If so, it returns {@code true}; if not, it checks if the  
  12.  * specified object is a list. If not, it returns {@code false}; if so,  
  13.  * it iterates over both lists, comparing corresponding pairs of elements.  
  14.  * If any comparison returns {@code false}, this method returns  
  15.  * {@code false}.  If either iterator runs out of elements before the  
  16.  * other it returns {@code false} (as the lists are of unequal length);  
  17.  * otherwise it returns {@code true} when the iterations complete.  
  18.  *  
  19.  * @param o the object to be compared for equality with this list  
  20.  * @return {@code true} if the specified object is equal to this list  
  21.  */   
  22. public boolean equals(Object o) {   
  23.     if (o == this)   
  24.         return true;   
  25.     if (!(o instanceof List))   
  26.         return false;   
  27.   
  28.     ListIterator e1 = listIterator();   
  29.     ListIterator e2 = ((List) o).listIterator();   
  30.     while(e1.hasNext() && e2.hasNext()) {   
  31.         E o1 = e1.next();   
  32.         Object o2 = e2.next();   
  33.         if (!(o1==null ? o2==null : o1.equals(o2)))   
  34.         return false;   
  35.     }   
  36.     return !(e1.hasNext() || e2.hasNext());   
  37. }  


P. S.: сделано http://aivolkov.ru/online-syntax-highlighter/

bugmaking

Previous post Next post
Up