In Java, can “void” be considered a primitive type?

后端 未结 7 1018
-上瘾入骨i
-上瘾入骨i 2021-01-17 10:21

I\'ve noticed eclipse JDT uses void as a primitive type. Can this be considered correct?

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-17 10:37

    I see you argue a lot about this but...

    hey guys, there is a function named isPrimitive() in java.lang.Class

    so why don't we invoke it with void class object and get the answer?

    besides, Void.TYPE is get using Class.getPrimitiveClass("void").

    So the fact is clear, void IS primitive.

提交回复
热议问题