page 76, "Working with Methods and Encapsulation" chapter . &
Chapter 8 makes much better reference variable to the address of "Working with Methods and Encapsulation" than Chapter . &
Page 76, 1. this is a keyword. That means you can't use it as variable name or class name.
I was wondering, shouldn't this sentence also include method name?
[HD Pg 75, Sec. 3.4.2 - when-is-this-necessary]
Moderator: admin
-
- Posts: 221
- Joined: Mon Nov 26, 2018 2:43 pm
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 75, Sec. 3.4.2 - when-is-this-necessary]
Yes, it seems the chapter numbers were not decided when it was written. Even so, the sentence is ok, "...the "Working with Methods and Encapsulation" chapter.", implies the chapter with title "Working with Methods and Encapsulation"
and may be interface name, enum name, and package name also But yes, the sentence could be restructured to make it more clear.Page 76, 1. this is a keyword. That means you can't use it as variable name or class name.
I was wondering, shouldn't this sentence also include method name?
If you like our products and services, please help us by posting your review here.
-
- Posts: 95
- Joined: Sat Dec 26, 2015 6:37 pm
- Contact:
Re: [HD Pg 75, Sec. 3.4.2 - when-is-this-necessary]
given
The compiler does not execute any code and it has no knowledge of the values that a variable might take during the execution of the program.
should beBut when you do name = name;, the compiler cannot distinguish between the two name variables. It thinks that name refers to the method parameter and assigns the value of the method parameter to itself, which is basically redundant and is not what you want.
?But when you do name = name;, the compiler cannot distinguish between the two name variables. It thinks that name refers to the method parameter and the JVM (later) assigns the value of the method parameter to itself, which is basically redundant and is not what you want.
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: [HD Pg 75, Sec. 3.4.2 - when-is-this-necessary]
No, this is fine. It is talking about what the compiler understands by name = name. The code name = name; implies that you are assigning the name to name. The actual assignment of the value is, of course, done by the JVM at runtime but the bytecode for that assignment is generated by the compiler.
In other words, " assigns the value of the method parameter to itself," means "the compiler generates the byte code that assigns the value of the method parameter to itself".
In other words, " assigns the value of the method parameter to itself," means "the compiler generates the byte code that assigns the value of the method parameter to itself".
If you like our products and services, please help us by posting your review here.
-
- Posts: 95
- Joined: Sat Dec 26, 2015 6:37 pm
- Contact:
Who is online
Users browsing this forum: No registered users and 57 guests