The Artima Developer Community
Sponsored Link

Java Answers Forum
i want to compare a character of a string

2 replies on 1 page. Most recent reply: Oct 11, 2002 8:46 AM by kemtis

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
patrick

Posts: 23
Nickname: patrick
Registered: Mar, 2002

i want to compare a character of a string Posted: Apr 8, 2002 12:19 AM
Reply to this message Reply
Advertisement
hi ,
i have a string that i want to compare each character to an other character how ca ni do that


Thomas SMETS

Posts: 307
Nickname: tsmets
Registered: Apr, 2002

Re: i want to compare a character of a string Posted: Apr 8, 2002 6:36 AM
Reply to this message Reply
Patrick,
This is definitively not clear !
Please explain more thoroughly what U want or ....
String s;
char ch; // character to find
for (int i = 0; i < s.length(); i++)
{
  if (s.lastIndexOf(ch) != -1)
    doSmthg();
  else 
    doSomeOtherThing();
}


Please note that java.lang.String contains that many API's that this is only one possible solution !


Thomas,
tsmets @ lautre . net

kemtis

Posts: 1
Nickname: joker
Registered: Oct, 2002

Re: i want to compare a character of a string Posted: Oct 11, 2002 8:46 AM
Reply to this message Reply
could you give me that method coz' i do need it also. i want to compare string by ascending.

Flat View: This topic has 2 replies on 1 page
Topic: fairly general question on java pgm distribution Previous Topic   Next Topic Topic: can some teach me how to do palindrome this is wat i have

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use