That isn't really an overlap; if you had ABCD and CDEF then the overlap would be CD.
You can try putting one String into a regular expression inside  and the seeing whether you can match the other. But then you would get ABCD matching FEDC on the DC. In the case you mention you would also have problems with the - because it is a special character.
There is lots and lots of information about regular expressions; the Java Tutorials is a good place to start.