标识符和变量之间有什么区别? [英] What is the difference between an identifier and variable?

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

问题描述

我对标识符有些困惑.在我的教科书中,它说:我们使用标识符来命名Java中的变量(以及许多其他东西)."

I'm a bit confused about identifiers. In my textbook it says, "We use identifiers to name variables (and many other things) in Java."

我不太确定这是什么意思.就像将变量...分配给变量一样吗?什么?

I'm not really sure what this means. Is it like assigning a variable...to a variable? What?

到目前为止,我的印象是:

So far, I'm getting this impression:

int a, b, c; a = 2; b = 99; c = a + b;

c是标识符吗?当它说使用标识符来命名变量"时,诸如intdoubleboolean之类的标识符是用来对变量进行分类的吗?请提供一些示例.

Is c an identifier? When it says, "Using identifiers to name variables," are identifiers like int, double, boolean, things used to categorize variables? Please provide some examples.

推荐答案

您可以将标识符视为变量的名称.我不会对此太费劲.

You can think of an identifier as variable's name. I wouldn't get too worked up about it.

例如:

int a;
a = 15;

在此示例中,a是引用具有相同名称的变量的标识符.如果a不是变量而是函数:

In this example, a is a identifier that refers to the variable with the same name. If a weren't a variable but a function:

int a()
{
}

a();

然后a仍将是一个标识符,但它将标识一个函数.就像里纳(Reena)"可以识别一个人和某种非营利组织一样.

Then a would still be an identifier but it would identify a function. Just as "Reena" can identify both a person and some kind of a non-profit organization.

这篇关于标识符和变量之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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