Checking lower alphabet in string
int n = input . length ( ) ; boolean hasLower = false , hasUpper = false , hasDigit = false , specialChar = false ; Set < Character > set = new HashSet < Character > ( Arrays . asList ( ' ! ' , ' @ ' , ' # ' , ' $ ' , ' % ' , ' ^ ' , ' & ' , ' * ' , ' ( ' , ' ) ' , ' - ' , ' + ' ) ) ; for ( char i : input . toCharArray ( ) ) { if ( Character . isLowerCase ( i ) ) hasLower = true ; if ( Character . isUpperCase ( i ) ) hasUpper = true ; if ( Character . isDigit ( i ) ) hasDigit = true ; if ( set . contains ( i ) ) specialChar = true ; }