是什么让 java 不是纯面向对象的语言?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6151497/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 14:34:15  来源:igfitidea点击:

what makes java not pure object oriented language?

java

提问by Pushpendra Kuntal

I think java is pure object oriented, but in real it is not. But i dont know why java is not pure object oriented language, please help me to find out the reason.

我认为 java 是纯面向对象的,但实际上并非如此。但是我不知道为什么java不是纯面向对象的语言,请帮我找出原因。

回答by Rom1

This is a homework question, right?

这是一个家庭作业问题,对吧?

Primitive types, that's why. For instance try this:

原始类型,这就是原因。例如试试这个:

int i = 42;
System.err.println(i.toString());

回答by JB Nizet

The usual objection is that Java is not "purely" OO because it has primitive types (int, double, etc.), which are not objects.

通常的反对意见是 Java 不是“纯粹的”面向对象,因为它具有不是对象的原始类型(int、double 等)。

回答by Waldheinz

To make proof by contradiction: Java has int, and int, like all primitive types in Java, is not an Object. There are possibly more reasons, though.

通过矛盾来证明:Java 有int, and int,就像 Java 中的所有原始类型一样,不是Object。不过,可能还有更多原因。