Question: how to check if a string contains only alphabets?
Answer: We can use the regex ^[a-zA-Z]*$ to check a string for alphabets. This can be done using matches() method of String class which tells whether or not the string matches the given regex.