Skip to content

Commit 3d14e42

Browse files
committed
Added index terms for 7.3
1 parent df5ff39 commit 3d14e42

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎source/ch_7_definingclasses.ptx‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public Fraction(Integer num, Integer den) {
233233
<p>
234234
Now we come to one of the major differences between Java and Python.
235235
The Python class definition used the special methods for addition and comparison that have the effect of redefining how the standard operators behave: in Python, <c>__add__</c> and <c>__lt__</c> change the behavior of <c>+</c> and <c>&lt;</c>, respectively.
236-
In Java there is <term>no operator overloading</term>.
236+
In Java there is no operator overloading.
237237
So we will have to write the method for addition a little differently.
238238
</p>
239239

@@ -248,12 +248,12 @@ public Fraction(Integer num, Integer den) {
248248
<ul>
249249
<li>
250250
<p>
251-
<term>Java is strictly pass-by-value.</term> For primitive types (like <c>int</c>), a copy of the value is passed. For object types (like our <c>Fraction</c>), a copy of the <em>value of the reference</em> (the memory address) is passed.
251+
<idx>pass-by-value</idx><term>Java is strictly pass-by-value.</term> For primitive types (like <c>int</c>), a copy of the value is passed. For object types (like our <c>Fraction</c>), a copy of the <em><idx>value of the reference</idx><term>value of the reference</term></em> (the memory address) is passed.
252252
</p>
253253
</li>
254254
<li>
255255
<p>
256-
<term>Python is pass-by-assignment</term> (or pass-by-object-reference). Since everything in Python is an object, the rule is consistent: a copy of the reference to the object is passed.
256+
<idx>pass-by-assignment</idx><term>Python is pass-by-assignment</term> (or pass-by-object-reference). Since everything in Python is an object, the rule is consistent: a copy of the reference to the object is passed.
257257
</p>
258258
</li>
259259
</ul>
@@ -282,7 +282,7 @@ public Fraction add(Fraction otherFrac) {
282282
</program>
283283

284284
<p>
285-
First you will notice that the <c>add</c> method is declared as <c>public Fraction</c> The <c>public</c> part means that any other method may call the <c>add</c> method.
285+
First you will notice that the <c>add</c> method is declared as <c>public Fraction</c> The <c><idx>public</idx><term>public</term></c> part means that any other method may call the <c>add</c> method.
286286
The <c>Fraction</c> part means that <c>add</c> will return a fraction as its result.
287287
</p>
288288

@@ -333,14 +333,14 @@ public Fraction add(Fraction otherFrac) {
333333
<p>
334334
In Java we can do runtime type checking, but the compiler will not allow us to pass an Integer to the <c>add</c> method since the parameter has been declared to be a Fraction.
335335
The way that we solve this problem is by writing another <c>add</c> method with a different set of parameters.
336-
In Java this practice is legal and common we call this practice <term>method overloading</term>.
336+
In Java this practice is legal and common we call this practice <idx>method overloading</idx><term>method overloading</term>.
337337
</p>
338338

339339
<p>
340340
This idea of method overloading raises a very important difference between Python and Java.
341341
In Python a method is known by its name only.
342342
In Java a method is known by its signature.
343-
The signature of a method includes its name, and the types of all of its parameters.
343+
The <idx>signature</idx><term>signature</term> of a method includes its name, and the types of all of its parameters.
344344
The name and the types of the parameters are enough information for the Java compiler to decide which method to call at runtime.
345345
</p>
346346

0 commit comments

Comments
 (0)