if ( Expression )
{
DoStuff
}
And you have the option of adding an else clause:
if ( Expression )
{
DoStuff
}
else
{
DoOtherStuff
}
which can be compounded if you need it:
if ( Expression )
{
DoStuff
}
else if ( AnotherExpression )
{
DoOtherStuff
}
else
{
DoYetOtherStuff
}
DoStuff, DoOtherStuff and DoYetOtherStuff can be
any Java commands and constructs you want.Expression and AnotherExpression can be any Java expression that evaluates to a Java boolean value (true or false).
Example:
if ( goatSize > 5 )
{
System.out.println("Dat's a mighty big goat you got der.");
}
else
{
System.out.println("Wut's wrong wit chyer goat der?");
}
Look on page 71 of Just Java 2 for more information on the if construct.