Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

immutability - Complete List of immutable JDK classes?

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

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

de-facto immutable will include for example java.lang.String - it might technically be mutable but de-facto it is not.

Also, are there Interfaces/Abstract classes which are required (as stated in the javadoc) to be immutable?

if you cannot provide a complete List, i would already be happy if you know a bunch of classes which state immutability in its javadoc..

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...