変数値が の場合に現在の反復をキャンセルしたいアクション リスナーがありますnull
。
public class ValidateListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
myCalendarKey mCal = Project5.verifyDate(month+"/"+day+"/"+year); //month day and year are defined, just not in this code display.
if (mCal == null) e.cancel(); //I need something to cancel the current ActionEvent if this returns true.
/* A lot more code down here that only works if mCal is defined */
}
}
if-else ステートメントを使用して、 if のすべてを実行し、 if の場合 mCal != null
は何もしないようにすることもできると思いますmCal == null
が、これを行うより良い方法はありますか?