lundi 5 février 2018

java if-else if ladder both getting executed

In the below code, both my if and else if block getting executed. In that CLIENTS, I am getting a list of clients as Arrays.asList. I have "ABC" client in the CLIENTS list as well as in the formBean.getClient.equalsIgnoreCase("ABC"). I want to execute only one statement.

public static final List<String> CLIENTS = new ArrayList<String>(Arrays.asList(new String [] {"ABC", "BBC", "CBC"}));

if (formBean.getClient != null && formBean.getClient.equalsIgnoreCase("ABC")
 && formBean.getInvestment.equalsIgnoreCase("Y")) {
    //statement 1
}
else if (CLIENTS.contains(formBean.getClient()) && (checkDate(dataOfCompany))){
//statement 2
}

Aucun commentaire:

Enregistrer un commentaire