(Official Java development engineer QQ group (27163376), please enter your ID to verify a book that answers the classic confusing points in java, a book that will definitely make your heart flutter. . . . Definitely "beans" worth it. . The purpose of the following method is to determine whether its only parameter is an odd number. Does this method work correctly? publicstaticbooleanisOdd(inti){returni=1;} Odd numbers can be defined as integers that have a remainder of 1 when divisible by 2. The expression icomputes the remainder when i divides by 2, so it seems that this program should work correctly. Sadly, it can't; it comes back with the wrong answer a quarter of the time. Why is a quarter? Since half of all int values ??are negative, the isOdd method will fail to discriminate against all negative odd numbers. Calling this method on any negative integer returns false, whether the integer is even or odd. This is a consequence of Java's definition of the remainder operator (%). The operator is defined to satisfy the following identity for all int values ??a and all non-zero int values ??b, <imgsrc="sad.gif"smilieid="2"border="0"alt=""/> a/b)
b (a==a....... This document includes the following attachments:
JAVA puzzles.pdf)