function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
Integer[] pesoCnpj = {1,2,3};
Because you declared the var but did not create the object:
Integer[] pesoCnpj = New Integer[]{1,2,3};
Thanks!
But, look this error.
System.StringException: Ending position out of bounds: 12: Class.Validacao.validaCnpj: line 31, column 1
public class Validacao { Integer[] pesoCnpj = new Integer[]{6,5,4,3,2,9,8,7,6,5,4,3,2}; //Validando o digito do CNPJ public Integer calculaDigito(String str, Integer[] peso){ Integer soma = 0; for(Integer i = str.length() - 1, digito; i >= 0; i--){ digito = Integer.valueOf(str.substring(i,i+1)); soma += digito*peso[peso.size() - (str.length() + i)]; } soma = 11 - Math.mod(soma,11); return soma > 9 ? 0 : soma; } //Fazendo a validação do CNPJ public Boolean validaCnpj(String cnpj){ Integer digitoV_1 = calculaDigito(cnpj.substring(0,12), pesoCnpj); Integer digitoV_2 = calculaDigito(cnpj.substring(0,12) + digitoV_1, pesoCnpj); return cnpj.equals(cnpj.substring(0,12) + digitoV_1.format() + digitoV_2.format()); } }
It means the string cnpj is not 12 characters long.
Because you declared the var but did not create the object:
All Answers
Because you declared the var but did not create the object:
Thanks!
But, look this error.
And this is the code of my class
It means the string cnpj is not 12 characters long.