List isEmpty()和size()==0 有什麼區別

luxika發表於2011-10-18
沒有區別,isEmpty()方法也是判斷size是否為0.

/**
* Tests if this list has no elements.
*
* @return <tt>true</tt> if this list has no elements;
* <tt>false</tt> otherwise.
*/
public boolean isEmpty() {
return size == 0;
}

相關文章