• Post Reply Bookmark Topic Watch Topic
  • New Topic

String contains problem  RSS feed

 
Balachandran Paranjothimani
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.
 
Campbell Ritchie
Marshal
Posts: 55768
163
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!