Code: Java
String str = new String();
 if (str.matches("^[a-zA-Z]+$")) // will only matches alphabets
 {
 }
 else {}