在Java中,可以“无效”被认为是原始类型? [英] In Java, can "void" be considered a primitive type?

查看:123
本文介绍了在Java中,可以“无效”被认为是原始类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到eclipse JDT uses void 作为原始类型。这可以被认为是正确的吗?

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

推荐答案

我发现,在这种情况下,你不能打败Java语言规范。非常清楚的是, void 不是原始的。

I find that, in cases like this, you can't beat going to the Java Language Specification. It is pretty clear about the fact that void is not a primitive.

首先, void 不在原始类型列表。后来,JLS明确指出:

First off, void is not in the list of primitive types. Later on, the JLS explicitly states:


Java编程语言不允许cast to void - void不是一种类型
http: //java.sun.com/docs/books/jls/third_edition/html/statements.html#5989 (强调我的)

此外, void 出现在

Furthermore, void appears in the list of keywords, not the list of literals.

原因你看到你所做的是很好地解释由Michael Borgwardt。

The reason that you saw what you did was explained nicely by Michael Borgwardt.

所以,回答你的标题:不。在Java中, void 不能被认为是原语。要回答你的身体:是的,Eclipse JDT代码对于需要做的是正确的。

So, to answer your title: no. In Java, void cannot be considered a primitive. To answer your body: yes, the Eclipse JDT code is correct for what it needs to do.

这篇关于在Java中,可以“无效”被认为是原始类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆