You Are Here:

Community: Developer Discussion Boards

#1 Old Exclamation How to verify if a string value in present in another string in J2ME? - 2009-01-17, 13:51

Join Date: Jan 2009
Posts: 8
nevinvj
Offline
Registered User
Normally in J2SE, one would use the contains() method found in the String class to verify whether the value of a particular string is present in another string.
For e.g., String a = "ecta"; and String b = "expectation";
The contains method can be easily used to verify whether the value of a is present in b in J2SE.
But I think that this method is omitted in J2ME. It is unavailable.
So how do I get through this problem in J2ME?

Thanks for the reply.

Best Regards,
Nevin
Reply With Quote

#2 Old Re: How to verify if a string value in present in another string in J2ME? - 2009-01-17, 14:50

Join Date: Jun 2003
Posts: 4,325
Location: Cheshire, UK
grahamhughes's Avatar
grahamhughes
Offline
Forum Nokia Champion
String.contains() wasn't added to J2SE until 1.5. It's really just a convenience, it's technically redundant. CLDC generally contains only things you really need.

In CLDC (and J2SE, prior to 1.5), you would use String.indexOf(String).

Code:
boolean b = s.contains(t);
becomes:

Code:
boolean b = (s.indexOf(t) >= 0);
Cheers,
Graham.
Reply With Quote

#3 Old Re: How to verify if a string value in present in another string in J2ME? - 2009-01-17, 18:44

Join Date: Jan 2009
Posts: 8
nevinvj
Offline
Registered User
Thank you very much Graham!
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Binary Messages on 3410 phone using J2ME affinitystudios Mobile Java General 3 2008-09-23 11:58
How can the WAP browser communicate to J2ME application? hbfornies Mobile Java General 20 2007-03-02 17:32
global root overflow(please help) sushant_125 Mobile Java Networking & Messaging & Security 3 2004-05-14 09:24
TinyLine SVG Minute Toolkit: Optimizing SVG for J2ME girow Mobile Java Media (Graphics & Sounds) 0 2003-05-05 19:44
TinyLine SVG Minute Toolkit for J2ME: version 1.4 released girow Mobile Java General 0 2003-05-05 17:25

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia