2
1

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 1 year has passed since last update.

Javaで使用すべきでないモジュール

Posted at

Javaではエラーも出ずにちゃんと動作するが、パフォーマンスやセキュリティの観点から使用すべきでないモジュールが存在します。
今回は非推奨のモジュールとそれに代わるものを紹介します。

java.util.Date/java.util.Calendar

Java8以降、java.util.Dateとjava.util.Calendarの使用は非推奨となっています。
代わりに、java.time.LocalDateやjava.time.LocalDateTimeなどを利用すべきです。

SimpleDateFormat

SimpleDateFormatはnewでインスタンス化が必要。また、スレッドセーフではありません。
代わりに、DateTimeFormatterの利用が推奨されます。

繰り返し処理中の+演算子による文字列連結

繰り返し処理の中ではStringBuilderを利用して文字列を連結するべきです。
+演算子による連結と比べると、連結回数が多い程、StringBuilderのほうが処理が早くパフォーマンスが良いので、
こちらを利用するべきです。

2
1
0

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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?