String comparision

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sgxbytes
    New Member
    • Sep 2008
    • 25

    String comparision

    Hi,
    I have two strings with values say like

    String s1 ="hello,test,fr om,one,party";
    String s2 = "into,bytes,hel lo,to";

    i need to compare s1 values with s2 values if exists i need to return the matched value.

    can any one help how to proceed.

    regards
    raj
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    What have you tried so far?
    Hint: You can split one of them into tokens using String.split.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      If you're really lazy, after the String.split(.. .) method have a look at the Arrays.asList(. ..) method and the List.retainAll( ...) method. Your program'll be a one liner.

      kind regards,

      Jos

      Comment

      Working...