• Post Reply Bookmark Topic Watch Topic
  • New Topic

String contains problem  RSS feed

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am on JDK 1.4 and I would like to know if there is a substitute for contains method found in String class in JDK 1.5. TIA.
 
Marshal
Posts: 59458
187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try the indexOf("abc") method. If you get a number it is in there; if it is not found you get -1. But what is wrong with the contains() method?

CR
 
Balachandran Paranjothimani
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nothing is wrong with contains. The deployment is targeted for WAS 6.0 which supports J2EE 1.4. String contains method is available only in Java 5.

Your code works. I did see that contains has the same implementation but just overlooked to pass the string to be tested. Thanks.
 
I do some of my very best work in water. Like this tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!