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

Example code in Scanner class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • None
    • core-libs
    • b28
    • generic
    • generic

        There is one using `System.in` as:
        ```
             Scanner sc = new Scanner(System.in);
        ```
        With JEP 400, the default charset and console charset may differ, thus this example may result in an unexpected one if the user tries to read a String from the scanner. This should be replaced with:
        ```
            Scanner sc = new Scanner(Console.reader())
        ```
        so that the user would not have to take encoding into consideration.

              naoto Naoto Sato
              naoto Naoto Sato
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: