Here you can find the source of lengthIfAllAlpha(String str)
private static int lengthIfAllAlpha(String str)
//package com.java2s; public class Main { private static int lengthIfAllAlpha(String str) { int len = (str == null) ? 0 : str.length(); for (int i = 0; i < len; ++i) { char c1 = str.charAt(i); if (!((c1 >= 'A' && c1 <= 'Z') || (c1 >= 'a' && c1 <= 'z'))) { return 0; }// w ww . j ava 2s . co m } return len; } }