1

I want to compare if string1 "stack" is in string2 "Welcome to stack overflow". How to achieve this in J2ME?

1 Answer 1

4

.contains() is worked for that. Why are you looking for alternative? But here is the same code which achieves if a string contains a substring;

if( string.indexOf("stack") >= 0 ) { // True

}else {

}

In anywhere of string, that search the "stack" and returns true or false.

1
  • 1
    J2ME doesn't have the String.contains() method, that's why Adilwaheed was looking for an alternative way
    – raghum
    Aug 6, 2014 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.