0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

重複チェックロジックを書くにはどのようにすれば可読性が高くなるのか

Posted at

重複しているか調べたいデータをList型で所持する。DBのレコードならSQLで取得してくる。
そのうえで例えば文字列の重複チェックなら、

sample.java
String searchStr = '調べたい文字列';
List<String> dataList =  '調べる対象のデータ';

if(dataList.contains(searchStr)){
   // 重複したときの処理

} else {
   // 重複しなかったときの処理

}

このように書くとあとで見たときにわかりやすいのではないだろうか。

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?