이것은 내 다른 질문 hereJava : Do 문의 내부 구문?
public void equipWep(String weapontoequip){
if(items.isEmpty() && weapons.isEmpty()){
System.out.println("You are not carrying anything.");
} else {
boolean weaponcheck_finished = false;
do {
for (String s : weapons) {
if (s.contains(weapontoequip)) {
System.out.println("You equip " + s + ".");
weaponcheck_finished = true;
} else {
System.out.println("You cannot equip \"" + weapontoequip + "\", or you do not have it.");
weaponcheck_finished = true;
}
}
}while(weaponcheck_finished == false);
}
}
이 메소드가 실행되면, 시스템은 아무것도 출력하지 않습니다 관련이있다. 일련의 인쇄 테스트를 통해, 나는 그것이 do-while
루프 안에 있음을 확인했습니다. 비록 그것이 for
루프 안에 들어가는 지 잘 모르겠다.
당신은 디버거를 사용하는 대신 단지 문을 인쇄 시도? –
그건 엉망이며, 다양한 명명 규칙이 있습니다. 그러나 무기가 있으면 'for' 루프 안에 들어갑니다. –