Stack 을 빈 것 으로 판단 하 는 방법의 empty () 와 isEmpty ()
/**
* Tests if this vector has no components.
*
* @return {@code true} if and only if this vector has
* no components, that is, its size is zero;
* {@code false} otherwise.
*/
public synchronized boolean isEmpty() {
return elementCount == 0;
}
/**
* Returns the number of components in this vector.
*
* @return the number of components in this vector
*/
public synchronized int size() {
return elementCount;
}
java. util. Stack 클래스 중:
/**
* Tests if this stack is empty.
*
* @return true
if and only if this stack contains
* no items; false
otherwise.
*/
public boolean empty() {
return size() == 0;
}
class Stack extends Vector
자바 util. Stack 류 에서 size () 방법 은 자바 util. Vector 의 size () 방법 을 사용 하 는 것 입 니 다. 그러면 소스 코드 에서 볼 때 empty () 와 isEmpty () 는 본질 적 인 차이 가 없습니다.스 택 이 비어 있 는 지 판단 할 때 stack. empty () 와 stack. isEmpty () 를 사용 하면 두 가지 방법 이 존재 하 는 클래스 만 다 를 수 있 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
JPA + QueryDSL 계층형 댓글, 대댓글 구현(2)이번엔 전편에 이어서 계층형 댓글, 대댓글을 다시 리팩토링해볼 예정이다. 이전 게시글에서는 계층형 댓글, 대댓글을 구현은 되었지만 N+1 문제가 있었다. 이번에는 그 N+1 문제를 해결해 볼 것이다. 위의 로직은 이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.