how to check if a string contains only characters in java code example Example: check if a string contains a character java string.indexOf('a')