United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4792350 : RFE: Add method boolean String.contains(String substring)

Details
Type:
Enhancement
Submit Date:
2002-12-11
Status:
Resolved
Updated Date:
2003-05-16
Project Name:
JDK
Resolved Date:
2003-05-16
Component:
core-libs
OS:
windows_98
Sub-Component:
java.lang
CPU:
x86
Priority:
P5
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

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


                                     
2004-06-14
EVALUATION

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



Hardware and Software, Engineered to Work Together