我注意到 eclipse JDT uses void
as a primitive type .这可以认为是正确的吗?
最佳答案
我发现,在这种情况下,您不能不去看 Java 语言规范。很明显 void
不是原语。
首先,void
不在 list of primitive types 中.后来,JLS 明确指出:
the Java programming language does not allow a "cast to void" — void is not a type http://java.sun.com/docs/books/jls/third_edition/html/statements.html#5989 (emphasis mine)
此外,void
出现在 list of keywords 中,而不是文字列表。
你看到你所做的事情的原因是explained nicely作者:Michael Borgwardt。
因此,回答您的标题:不。在 Java 中,void
不能被视为原语。回答你的 body :是的,Eclipse JDT 代码对于它需要做的事情是正确的。
关于java - 在Java中, "void"可以被认为是原始类型吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4681568/