为什么java中的数据类型不是对象? [英] Why Data type in java are not object?

查看:153
本文介绍了为什么java中的数据类型不是对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我之前研究过java数据类型,发现它们是原始类型。因为java是面向对象的,但它的数据类型不是。为什么会这样?

I have studied about java datatype very earlier and found that they are primitive type. As java is object oriented but its data types are not. why is it so?

推荐答案

据说Java编程语言意味着Java中的所有内容都是对象简单。由于原始数据类型消耗更少的内存并且可以更快地访问,因此它们不是对象。等效的Wrapper类也可以在java中使用,如Integer,Short等。如果需要,它们可以用作对象。但是,包装器类将存储在Heap中并且它们很慢。

It is said that everything in Java is an Object at the same time the Java Programming Language is meant to be simple. Since the primitive data types consume less memory and can be accessed faster, they are not objects. The equivalent Wrapper classes are also available in java like "Integer" "Short" etc. They can be used as objects if you want. However, the wrapper classes will be stored in Heap and they are slow.

这篇关于为什么java中的数据类型不是对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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