idcard_no='111111198101017000' ; idcard_no_array = idcard_no.substring(0,17).toCharArray(); int[] c = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 ]; char[] r = [ '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' ]; int result = 0; for (int i = 0; i < idcard_no_array.length; i++) { result += c[i] * Integer.parseInt(String.valueOf(idcard_no_array[i])); } num18 = r[result % 11]; SampleResult.setResponseMessage(num18.toString()); SampleResult.setResponseData(num18.toString().getBytes());