Java 一个语句中有两个等号? [英] Java two equal signs in one statement?
问题描述
谁能帮我理解以下代码的作用以及带有两个等号的行的作用?在这个构造函数中,something equal to something 是如何工作的?
Can someone help me understand what the following code does and what the line with two equal sign does? How does something equal to something equal to something work in this constructor?
public More ...LinkedList() {
header.next = header.previous = header;
}
这是我看到这个网站的链接,我正在努力弄清楚:http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/LinkedList.java#LinkedList.0header
Here is the link to the website where I saw this and I'm trying to figure it out: http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/LinkedList.java#LinkedList.0header
推荐答案
从右到左阅读赋值语句:
Read assignment statement from right to left:
- 将
header
分配给header.pevious
- 将
header.previous
分配给header.next
- assign
header
toheader.pevious
- assign
header.previous
toheader.next
底线:在这一行之后,header.previous
header.next
将引用 header
.
The bottom line: after this line both header.previous
header.next
will refer to header
.
这篇关于Java 一个语句中有两个等号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!