Skip to content

Instantly share code, notes, and snippets.

View Kauavitorio's full-sized avatar

Kaua Vitorio Kauavitorio

View GitHub Profile
@Kauavitorio
Kauavitorio / CPF Validation - Java Android Studio.java
Last active June 2, 2021 01:53
Method for validating CPF in java
private static final int[] WeightCPF = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2};
public static boolean isValidCPF(String cpf) {
cpf = cpf.trim().replace(".", "").replace("-", "");
if (cpf.length() != 11) return false;
for (int j = 0; j < 10; j++)
if (padLeft(Integer.toString(j), Character.forDigit(j, 10)).equals(cpf))
return false;