Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8305158

The java.util.Arrays class should be declared final

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • core-libs
    • None
    • minimal
    • The class is unlikely to be overridden in production code.
    • Java API
    • SE

      Summary

      The java.util.Arrays class should be declared final.

      Problem

      Non-instantiable utility classes should be declared final and have a private constructors.

      See Effective Java, Third Edition, Joshua Bloch (for example, Item 19 or Item 22).

      Solution

      Declare the class 'final'.

      Specification

      The class should be declared 'final'. This means, any attempt to create a sub-class will fail. The Arrays class only contains static methods which can be shadowed but not overridden.

            pminborg Per-Ake Minborg
            pminborg Per-Ake Minborg
            Roger Riggs
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: