In Java, do primitive types and arrays have a containing package?

后端 未结 4 599
野性不改
野性不改 2020-12-11 05:28

In Java, do primitive types and arrays have a containing package?

Probably not, but just want to be certain.

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 06:02

    No since they are language constructs and not classes per-se.

    You can however have a class representing a primitive type in the wrapper for instance:

    Integer.TYPE et al. useful for reflection.

    But you'll see that still those don't have a package ie.

    Integer.TYPE.getPackage()
    

    Returns null

提交回复
热议问题