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

if (matcher.find()) written after sysout(matcher.find()) and it returns true but not going inside if condition

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.8.0_111"
      Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      ver-Windows 7 Professional

      A DESCRIPTION OF THE PROBLEM :
      for (int k = 0; k < parts.length-1; k++) {
              Matcher match=Pattern.compile("[A-Z]+").matcher((CharSequence) parts[k]);
      System.out.println(match.find());
      if(match.find() && len <= parts[k].length()) {
      len = parts[k].length();
      }
      System.out.println(len);
      }

      In this piece of code condition is true but control is not passing to if block. But if i remove "System.out.println(match.find());" control is going inside if condition. Acutally it doesnot affect the condition but it is affecting. So i think this is a bug.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      the same code of the description block , you can use to reproduce the bug.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "System.out.println(match.find());" this line should not affect the output of the program but it is affecting.

      REPRODUCIBILITY :
      This bug can be reproduced always.

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: