JDK-4792350 : RFE: Add method boolean String.contains(String substring)
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 1.4.0
  • Priority: P5
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_98
  • CPU: x86
  • Submitted: 2002-12-11
  • Updated: 2017-05-16
  • Resolved: 2003-05-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
Description

Name: jl125535			Date: 12/11/2002


FULL PRODUCT VERSION :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

FULL OPERATING SYSTEM VERSION :

All.

ADDITIONAL OPERATING SYSTEMS :

All.

A DESCRIPTION OF THE PROBLEM :
Quite frequently I would like to check whether one String
contains another as a substring, without caring where the
substring occurs. I can use <code>boolean contains =
(str1.indexOf(str2) > -1);</code>, but this is inelegant,
especially for a frequent idiom. I would prefer a method in
String which checked this for me.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Look through the String API. Observe that none of the
methods with return type boolean do this.

EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected such a method to exist. It doesn't.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER WORKAROUND :
boolean contains = (str1.indexOf(str2) > -1);

(Alternatively, hack rt.jar, but I don't think the licence
allows this).
(Review ID: 164276) 
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b07
14-06-2004

EVALUATION This will be proposed for Tiger. ###@###.### 2002-12-16
16-12-2002