Java Assignment operators

Source: Internet
Author: User

Many people know that the assignment operator is the assignment and give the left-hand answer to the right, but it's wrong. we're not learning math, we're learning programming, and his assignment is just the Opposite. The assignment in Java is to give the right value to the variable name on the left. for example: int i = 100; 100 this value to the I variable, I get this fast 100 memory space address, do not know what is memory space address no matter what will be explained later, you can understand that I get 100. What if I put i = 1000; Then I re-point to 1000 of the memory space address, the original 100 of the memory space because there is no reference relationship by the garbage disposal mechanism to clear out. 4.1 is shown below:

650) this.width=650; "src=" http://img.mp.itc.cn/upload/20160405/20bc11385b8b450ab5d8648994341a77_th.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

The assignment operator is to give the right value to the left variable, the variable gets the address of the value space, if the re-opening a space to save the value and this value is given to the variable, then the variable will be the new value space of the address, and the original value because no recipient will be recycled. Running result 4.12 Shows:

650) this.width=650; "src=" http://img.mp.itc.cn/upload/20160405/d57ee048c51546ee847c0b1db0dc47de.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

The assignment operator also has a fancy write such as: int a,b,c,d,e; a=b=c=d=e=200; Does this look like a good writing? These variables they all got 200 then let's see the Results. 4.13 is shown below:

650) this.width=650; "src=" http://img.mp.itc.cn/upload/20160405/8b3a3ac11bce44089458eb4cc113fbad.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

Figure 4.13

Assign 200 to e, E assigns d, D assigns a value to c, C assigns to b, and B assigns a value to a actually 200 to them, they all point to the same piece of 200 space address.

Although this kind of writing is relatively shorthand code, but this kind of writing must not be used, He is the Java inside the unique wording, in addition to the Java language there is no other language has this kind of writing, this writing is not universal. As a team to open up the most important is a team inside everyone knows the writing, easy to understand easy to read.

The real master of his grammar is very simple and easy to understand the readability is very strong that is the real master, in the university you can write a complex variety of writing to install forcing students will feel you are very bad. But in the real business you are not what, the more complex the wording of the enterprise inside this is a bad code is not a bit of Readability.

General Wording: int a,b,c,d,e; A = 200; b = 200; c = 200; D = 200; E = 200; This kind of writing is more troublesome than it is, but it is very easy to understand. For a programmer who is not very good, this writing is easy to understand, and if that is the way it is written, they may not be able to think about it. We write code first is to let the computer to execute, the second is to the team to understand, easy to understand cooperation is relatively easy. 4.14 is shown below:

650) this.width=650; "src=" http://img.mp.itc.cn/upload/20160405/e61658a0b6524c8da511e9d393bb2468.jpg "style=" border:0px;margin:0px;padding:0px;font-size:0px; "/>

Figure 4.14

Technology Sharing: Www.kaige123.com

This article is from the "11247808" blog, please be sure to keep this source http://11257808.blog.51cto.com/11247808/1889063

Java Assignment operators

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.