Java에서 pop 메서드를 구현했습니다. 목록에 요소 하나가 있지만 구분 기호 일치에 사용합니다.POP 메서드 링크 목록
public int length(){
Node current = this.head;
int length = 0;
while(current != null){
current = current.getNextNode();
length += 1;
}
return length;
}
public char pop(){
Node current = this.head;
Node lastN = this.last;
for(int i = 0; i < length() - 2; i++){
current = current.getNextNode();
}
current.setNextNode(null);
this.last = current;
return lastN.getBracket();
}
length가> = 1 인 경우 첫 번째 요소를 팝하는 방법 또는 내 코드를 개선하기위한 제안.
그래,하지만 연습 목적으로하고 싶습니다. 또한 수동으로하는 것이 정말 중요하고 좀 생각할 수 있습니다. –
님이 아이디어를 추가했습니다. – manuelvigarcia
"초기"사례 아이디어를 확인 했습니까? – manuelvigarcia