Tuesday, 15 June 2010

java - Compare String of patterns -


I have a string in which string s1 = "1 2 7 8"
< Now let me assume that I have two strings string s2 = "1 7 8" and string s3 = "1 2 8"

But when I do s1.contanis (s2)

There is another easy way to compare the type of pattern, without dividing each one and comparing it one by one?

will work to check if s1 contains s2 < / Code> contains all elements (separated by a space):

  eraseus. The list includes (s1.split ("")). Everyone (erase.Sistrict (s2.split ("")));   

Full code:

  public square string intensification {public static zero main (string [] args) {last string s1 = "1 2 7 8" ; Last string s2 = "1 7 8"; Last string s3 = "1 2 8"; System.out.println (stringcontent number (S1, S2)); System.out.println (string contentguns (S1, S3)); } Private steady boolean string syntax (string s1, string s2) {return arrays.asList (s1.split ("")). All (arrays.asList (s2.split (""))); }}    

No comments:

Post a Comment