Integer as primitive type

前端 未结 4 513
不知归路
不知归路 2020-12-19 04:45

Why there is primitive type for integer(int) even though we have an object for integer as Integer? But the same is not with String type. There is no such primitive type for

4条回答
  •  抹茶落季
    2020-12-19 05:27

    This is because processors (CPUs) have direct support for integer types but not for strings. And for performace reasons Java supports some native types that are likely to be supported by the processors the JVM might run on.

提交回复
热议问题