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

String.startWith returns incorrect result in a specific scenario provided

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      java version "17.0.8" 2023-07-18 LTS
      Java(TM) SE Runtime Environment (build 17.0.8+9-LTS-211)
      Java HotSpot(TM) 64-Bit Server VM (build 17.0.8+9-LTS-211, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      Here is unbelievable scenario, it outputs "false" instead of "true":

      public class Test {
          public static void main(String[] args) {
              System.out.println("---\n" +
                      "title: \"Upsun - Definition, Etymology, And Usage in Modern English\"".startsWith("---\n"));
          }
      }


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run this code:

      public class Test {
          public static void main(String[] args) {
              System.out.println("---\n" +
                      "title: \"Upsun - Definition, Etymology, And Usage in Modern English\"".startsWith("---\n"));
          }
      }


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "true" in console output
      ACTUAL -
      "false"

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: