나는 스위치 또는 뭔가 다른 케이스에서 여러 번 호출 할 수있는 자바 코드를 작성하고 싶습니다. 중간에 대부분 또는 모든 케이스에 대해 동일한 코드를 사용합니다. 지금은 대소 문자를 구분하는 코드로 둘러 쌓여 있기 때문에 각각의 경우에 대해 코드의 절반을 반복해야합니다. 내 마음의 코드는, 그냥 내가 존재하는 경우는 아마 휴식 이외의 어떤 것을 이해하는 경우에 다음 호출 할 때까지 실행을 중지 의미 0-3에서이 같은 변수 범위를보고 휴식 것이같은 케이스를 여러 번 호출하는 스위치
switch(variable){
case 0:
case 1:
if(other factors)
//add item to next spot in array
case 2:
case 3://all cases
//add items to next 3 spots in array for all cases
break;
case 0:
case 1:
if(other factors)
//add item to next spot in array
case 2:
case 3://all cases
//add more items to next spot in array
break;
case 1:
case 2:
if(other factors2)
//add item to next spot in array
break;
case 3:
//add item to next spot in array
case 0:
case 1:
case 2://all cases
//add items to next spot in array
break;
case 1:
case 2:
if(other factors2)
//add item to next spot in array
break;
case 3:
//add item to next spot in array
}