Complete List of immutable JDK classes?

前端 未结 3 2018
北海茫月
北海茫月 2020-12-14 23:49

is there a list of de-facto immutable classes in the jdk?

technically Immutable classes include the obvious Integer, Double etc..

de-facto i

3条回答
  •  眼角桃花
    2020-12-15 00:42

    I try to compile the list as much as I can:

    1. java.lang.String The wrapper classes for the primitive types:
    2. java.lang.Integer
    3. java.lang.Byte
    4. java.lang.Character
    5. java.lang.Short
    6. java.lang.Boolean
    7. java.lang.Long
    8. java.lang.Double
    9. java.lang.Float
    10. java.lang.StackTraceElement (used in building exception stacktraces)
    11. Most of the enum classes
    12. java.math.BigInteger
    13. java.math.BigDecimal
    14. java.io.File
    15. java.awt.Font
    16. java.awt.BasicStroke
    17. java.awt.Color
    18. java.awt.GradientPaint,
    19. java.awt.LinearGradientPaint
    20. java.awt.RadialGradientPaint,
    21. java.awt.Cursor
    22. java.util.Locale
    23. java.util.UUID
    24. java.util.Collections
    25. java.net.URL
    26. java.net.URI
    27. java.net.Inet4Address
    28. java.net.Inet6Address
    29. java.net.InetSocketAddress
    30. most subclasses of java.security.Permission

提交回复
热议问题