내부에 자바 클래스가 있습니다. 조건을 기반으로 정수 값을 반환해야하는 메서드가 있습니다. 아래에 나와있는 설명과 같이 클래스의 메서드 내부에 일부 조건을 넣었습니다. 이 조건이 실행될 때 작성됩니다.조건이 여러 개있는 경우
def()
if
조건 내 논리가 올바른지 여부를 알려주고 실행 조건에 따라 조건이 남아 있는지 여부를 알려주십시오.
class abc
{
private static SUCCESS = 1;
private static FAILURE = 2;
public void int def()
{
if (a=20 && b==30)
{
if (c==30 && d==40) // nesting IF condition will go if a=20 & b=30
{ // do something
return SUCCESS; // IF this condion is met will it check remaing conditions or not
}
else
{
return FAILURE; // IF this condion is met will it check remaing conditions or not
}
}
else if(g==50 && d==60)
{
// do something
if (t==56 && p==98) // nesting IF condition will go if g=50 & d=60
{
// do something
return SUCCESS; // IF this condion is met will it check remaing conditions or not
}
return FAILURE; // IF this condion is met will it check remaing conditions or not
}
else
return FAILURE; // default return means if any othe if or else if block is satisfied then this default value will be returned from the method
}
}
코드에 문제가 있는지 실제로 테스트 해 보셨습니까? 아니면 우리가 관계없이 (우리는하지 않을 것입니다) 확인하길 원하십니까? –
@AndrewMarshall 어떤 조건이 충족되면 조건이 충족되면 반환 명령문이 실행될 것이라고 기대하는 방식으로 조건을 추가하는 방식을 알려주십시오. 그러면 조건이 추가로 확인되거나 – user1944559
이 다시 나타납니다. 왜 다른 입력 값을 사용하여 프로그램을 실행하고 출력 결과가 예상대로인지 확인하여 직접 확인할 수 없습니까? –