Darryl said:
String a = "abcdefg";
String b = "cde";
boolean isSubset = a.indexOf(b) != -1;
Why would we need a specific function to do that for us?
Actually there is, since 5.0, a method to check indexOf against -1.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#contains(java.lang.CharSequence)
The original question was about a subset rather than a subsequence,
which shows a failure to understand the nature of string. A string is a
sequence of characters/code points.
If you want to perform set operations, use a set.
Collection<Character> a = Arrays.asList(new Character[] {
'a', 'b', 'c', 'd', 'e', 'f', 'g'
});
Set<Character> b = new HashSet<Character>(Arrays.asList(new Character[]{
'a', 'd', 'g'
}));
b.removeAll(a);
boolean isSubset = b.isEmpty();
(Usual disclaimer. Not optimised.)
Tom Hawtin