Next:1.6.4 Help Methods, Packages, Up:
Typed exception used when opening an existing PDF document. Gets thrown when the document isn't a valid PDF document according to iText, but it's different from the InvalidPdfException in the sense that it may be an iText limitation (most of the times it isn't but you might have bumped into something that has been added to the PDF specs, but that isn't supported in iText yet). In the example of rolling a six-sided die 20 times, the probability p of rolling a six on any roll is 1/6, and the count X of sixes has a B(20, 1/6) distribution. The mean of this distribution is 20/6 = 3.33, and the variance is 20.1/6.5/6 = 100/36 = 2.78.
1.6.3 Inheritance and the Previous:1.6.3 Inheritance and the1.6.3.1 Overriding equals
As an example of inheritance, consider the methodwhich is defined in the class Object, the superclass of all Javaclasses. Any Java class that is defined without a designatedsuperclass is an immediate subclass of theGobdocuments 1 6 Equals A Mile
identity. Two object references are identical if and only if theyrefer to exactly the same object (produced by a particularnew operation).For some classes, identity is the appropriate definition for equality,but for many others it is not. In the built-in class String, the equals method is redefined to compare the sequences of characters instrings, so that copies of the same string are considered equal. Theredefinition of equals only affects the class String andany subclasses that it might have. This selective form of methodredefinition is called method overriding.
Finger Exercise Load the sample program intList into theDrJava Definitions window. Override the definition of equals for both Empty and Cons to match the definitionof the equal? function in Scheme on lists of integers. TheScheme equal? function compares two lists to determine if theycontain the same sequence of elements. Try evaluating a substantialset of test cases in the Interaction window of DrJava.
Exercise Load the saved program file ObjectList into the DrJava Definitions window. Override the definition of equals for both Empty and Cons to match the definitionof the equal? function in Scheme. The Scheme equal?function uses the equal? method to compare elements.
Next:1.6.4 Help Methods, Packages, Up:1.6.3 Inheritance and the Previous:
Gobdocuments 1 6 Equals A Mile
identity. Two object references are identical if and only if theyrefer to exactly the same object (produced by a particularnew operation).For some classes, identity is the appropriate definition for equality,but for many others it is not. In the built-in class String, the equals method is redefined to compare the sequences of characters instrings, so that copies of the same string are considered equal. Theredefinition of equals only affects the class String andany subclasses that it might have. This selective form of methodredefinition is called method overriding.
Finger Exercise Load the sample program intList into theDrJava Definitions window. Override the definition of equals for both Empty and Cons to match the definitionof the equal? function in Scheme on lists of integers. TheScheme equal? function compares two lists to determine if theycontain the same sequence of elements. Try evaluating a substantialset of test cases in the Interaction window of DrJava.
Exercise Load the saved program file ObjectList into the DrJava Definitions window. Override the definition of equals for both Empty and Cons to match the definitionof the equal? function in Scheme. The Scheme equal?function uses the equal? method to compare elements.
Next:1.6.4 Help Methods, Packages, Up:1.6.3 Inheritance and the Previous:1.6.3 Inheritance and theCorky Cartwright
2000-01-07-->
The <
(less than), >
(greater than), <=
(less than or equal), and >=
(greater than or equal) comparison, also known as relational, operators compare their operands. Those operators are supported by all integral and floating-point numeric types.
Note
For the , <
, >
, <=
, and >=
operators, if any of the operands is not a number (Double.NaN or Single.NaN), the result of operation is false
. That means that the NaN
value is neither greater than, less than, nor equal to any other double
(or float
) value, including NaN
. For more information and examples, see the Double.NaN or Single.NaN reference article.
The char type also supports comparison operators. In the case of char
operands, the corresponding character codes are compared.
Enumeration types also support comparison operators. For operands of the same enum type, the corresponding values of the underlying integral type are compared.
The and !=
operators check if their operands are equal or not.
Less than operator <
The <
operator returns true
if its left-hand operand is less than its right-hand operand, false
otherwise:
Gobdocuments 1 6 Equals 2 Eggs
Greater than operator >
The >
operator returns true
if its left-hand operand is greater than its right-hand operand, false
otherwise:
Less than or equal operator <=
The <=
operator returns true
if its left-hand operand is less than or equal to its right-hand operand, false
otherwise:
Greater than or equal operator >=
The >=
operator returns true
if its left-hand operand is greater than or equal to its right-hand operand, false
otherwise:
Operator overloadability
A user-defined type can overload the <
, >
, <=
, and >=
operators.
If a type overloads one of the <
or >
operators, it must overload both <
and >
. If a type overloads one of the <=
or >=
operators, it must overload both <=
and >=
.
C# language specification
For more information, see the Relational and type-testing operators section of the C# language specification.