Can Create a New primitive datatype in Java

后端 未结 5 2137
闹比i
闹比i 2020-12-11 02:53

First thing I want to clarify here, this question is because of curiosity. I am not facing any issue.

There are many primitive types available in Java byte

相关标签:
5条回答
  • 2020-12-11 03:22

    Primitive types are the ones defined by the language itself. In Java you can only define new types as Classes all derived from the common base class called Object.

    0 讨论(0)
  • 2020-12-11 03:32

    You all are wrong. Yes. You can. As a rule, you do not need a completely new primitive type. So, you don't need to rebuild JVM. Usually, you only need to "pack" or "cast" your new primitive type to an existing and define some operations like "+" with its wrapper.

    You can do it relatively simply with original JVM, but with your own Java compiler. Good luck!

    0 讨论(0)
  • 2020-12-11 03:36

    You could, but then it wouldn't be Java anymore.

    0 讨论(0)
  • 2020-12-11 03:36

    Simply No, You can not create primitive datatype.

    Primitive datatype means which are provided and existed in language feature. Basically Java support this for performance reason and perform arithmetic operation.

    You can create a user defined datatype using concept of class and object.

    0 讨论(0)
  • 2020-12-11 03:40

    You cannot create your own primitive datatype.

    As the Java documentation explains: A primitive type is predefined by the language and is named by a reserved keyword.

    0 讨论(0)
提交回复
热议问题