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

后端 未结 7 1107
-上瘾入骨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:42

    From your link:

    Note that "void" is special in that its only legitimate uses are as a method return type and as a type literal.

    Note also that this is a class concerned with AST nodes, i.e. the syntax of the Java language.

    Basically, when modelling the language syntax, void appears in some of the same places as primitive types, so when representing the syntax as a Java class, you have to classify it similarly.

提交回复
热议问题