I tried to check the validation of credit card using Luhn algorithm, which works as the following steps:
Double every second digit from right to left. If do
I took a stab at this with Java 8:
public static boolean luhn(String cc) {
    final boolean[] dbl = {false};
    return cc
            .chars()
            .map(c -> Character.digit((char) c, 10))
            .map(i -> ((dbl[0] = !dbl[0])) ? (((i*2)>9) ? (i*2)-9 : i*2) : i)
            .sum() % 10 == 0;
}
Add the line
            .replaceAll("\\s+", "")
Before
            .chars()
If you want to handle whitespace.
Seems to produce identical results to
return LuhnCheckDigit.LUHN_CHECK_DIGIT.isValid(cc);
From Apache's commons-validator.