Today I came across writing this code:
if("Name".equals(fieldName) || "ID".equals(fieldName)
|| "password".equals(fieldName) || "email".equals(fieldName)){
//do something.
}else{
//for other 76 properties do something.
}
I am comparing fieldName with four properties hence I have written four conditions. Is there a way in Java to combine all four conditions and write it as a single condition which satisfies my requirement. For instance
if(fieldName IN ("Name", "ID", "password", "email"){
//do something. .
}
.
.
.
Are there any methods or workaround to achieve this?