Java中的Object,Reference ID和Reference Variable之间有什么区别? [英] What is the difference between an Object , Reference ID , and Reference Variable in Java?

查看:302
本文介绍了Java中的Object,Reference ID和Reference Variable之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java中的以下内容之间有什么区别?

What is difference between the following in java :

  1. 对象

  1. Object

参考ID

参考变量

当我看到这样的语句时:

When I see statements like this:

Emp e = new Emp();

这里Emp是类,但是e不是它的对象?如果是这样..在其他地方我已经看到了:

Here Emp is class, but e is not its object? If that is so .. somewhere else I have seen this:

如果是这样的话,那么..somewhere就像

cos if it is so then ..somewhere is see like

Emp e = new Local(); 

其中local是Emp的子类.那么e在这种情况下是什么意思?它有什么作用?

Where local is a child class of Emp. So what does e mean in this case? What does it hold?

推荐答案

对象本质上是堆中生活的一块内存. (对象的部分内存结构包括对该对象类的引用.)

An object is, essentially, a chunk of memory living in the heap. (Part of the memory structure of objects includes a reference to the class of that object.)

对象变量(如本例中的e)包含对驻留在堆中的对象的引用.

Object variables in Java (like e, in this example) contain references to objects living in the heap.

类与所有这些类完全不同;它们可能描述了这种类型的对象的结构,并具有方法实现等,但是类与其他对象生活在完全不同的内存区域中.

Classes are completely different from all of these; they might describe the structure of objects of that type, and have method implementations and the like, but classes live in an entirely different area of memory from other objects.

这篇关于Java中的Object,Reference ID和Reference Variable之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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