我有一个java类里面有一个方法需要根据现在满足的条件返回一些整数值,我if...else
在类的方法中放置了一些条件,如下所示,并在注释中我写了这个条件何时执行。
请告知我在方法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
}
}