mardi 19 novembre 2019

Is there a way to check which conditional in an or statement resulted in the code being ran?

            System.out.println("Both are null");
            return;
        }
        else if(startingDate.getValue()==null){
            System.out.println("Start date is null");
            return;
        }else if(endingDate.getValue()==null){
            System.out.println("Ending date is null");
            return;
        }
    }

Instead of this I would like to shorten my code down to something like

            System.out.println(x + " is null");
        }

Where x is the DatePicker that returned null. Is there any way to do this, or do I already have the shortest method?

Aucun commentaire:

Enregistrer un commentaire