Bifalgorithm post · Computer science one · Comparing Strings and Characters

How can comparison operators be used with characters in Java?

How can comparison operators be used with characters in Java? (Computer science one · Comparing Strings and Characters) — "The comparison operators in Table 27…

Ideas in this flowchart

  • Comparison operators can be used with single characters in Java.
  • The ASCII table associates each alphanumeric character, symbol, and whitespace character with an integer from 0 to 127.
  • Character comparisons are determined by the ordering of their ASCII integer values.
  • Uppercase letters are ordered before lowercase letters in the ASCII table.
  • ('A' < 'a') is true because 'A' is 65, 'a' is 97, and 65 < 97.
  • Additional character-comparison examples are shown in Table 27.4.
  • ('A' == 'a') is false.
  • ('A' < 'Z') is true.
  • ('0' < '9') is true.
  • ('\n' < 'A') is true.
  • (' ' < '\n') is false.
Feed/

How can comparison operators be used with characters in Java?

No cover

Channel

Computer science one

1 page

"The comparison operators in Table 27.1 can also be used for single characters because of the nature of the ASCII text table (see Table 2.4). Each alphanumeric character, including the various symbols and whitespace characters, is associated with an integer 0–127. We can therefore write statements like ('A' < 'a'), which is true since uppercase letters are ordered before lowercase letters in the ASCII table ('A' is 65 and 'a' is 97 and so 65 < 97 is true). Several more examples can be found in Table 27.4.\n\nComparison | Example | Result\n\n| ('A' < 'a') | true\n\n| ('A' == 'a') | false\n\n| ('A' < 'Z') | true\n\n| ('0' < '9') | true\n\n| ('\n\n' < 'A') | true\n\n| (' ' < '\n\n') | false\n\nTable 27.4.: Character comparisons in Java"

Flowchart preview
👍
0
0 comments0 shares

Sign in to view and post comments.