Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6985556

java - nuts and bolts - Java basics typo

XMLWordPrintable

    • b08
    • generic
    • generic
    • Verified

      http://download.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

      In the paragraph near the bottom of the page:

      Literals of types char and String may contain any Unicode (UTF-16) characters. If your editor and file system allow it, you can use such characters directly in your code. If not, you can use a "Unicode escape" such as '\u0108' (capital C with circumflex), or "S\u00ED se\u00F1or" (Sí Señor in Spanish). Always use 'single quotes' for char literals and "double quotes" for String literals. Unicode escape sequences may be used elsewhere in a program (such as in field names, for example), not just in char or String literals.

      The problem lies here:

      "S\u00ED se\u00F1or" (Sí Señor in Spanish)

      The resulting text is wrong. It should be: Sí señor <-Note the lower case 's' in señor, because the original string had a lower case s in it. Java.lang.String is powerful, but not this good.

            skannan Sowmya Kannan (Inactive)
            skannan Sowmya Kannan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: