You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -608,6 +612,7 @@ public boolean equals(Fraction other) {
608
612
}
609
613
</code>
610
614
</program>
615
+
</listing>
611
616
612
617
<p>
613
618
One important thing to remember about <c>equals</c> is that it only checks to see if two objects are equal – it does not have any notion of less than or greater than.
@@ -634,14 +639,15 @@ public boolean equals(Fraction other) {
634
639
Here is code that makes the <c>Fraction</c> class a child of <c>Number</c>:
635
640
</p>
636
641
637
-
638
-
<programxml:id="pjava-extends"language="java">
642
+
<listingxml:id="pjava-extends">
643
+
<programlanguage="java">
639
644
<code>
640
645
public class Fraction extends Number {
641
646
...
642
647
}
643
648
</code>
644
649
</program>
650
+
</listing>
645
651
646
652
<p>
647
653
<idx><c>extends</c></idx>
@@ -685,8 +691,8 @@ public class Fraction extends Number {
685
691
This really isn’t much work for us to implement these methods, as all we have to do is some type conversion and some division:
0 commit comments