Have the data you want to check for duplication in List type. If it is a DB record, it will be fetched by SQL. On top of that, for example, when checking for duplicate character strings,
sample.java
String searchStr = 'The string you want to look up';
List<String> dataList = 'Data to be examined';
if(dataList.contains(searchStr)){
//Processing when duplicated
} else {
//Processing when there is no duplication
}
If you write it like this, it will be easier to understand when you look at it later.
Recommended Posts