Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static boolean isIsracardValid(String cardNumber) { int sum = 0; int len = cardNumber.length(); // If the number is less than 9 digits if (len == 8) { cardNumber = "0" + cardNumber; len++; } for (int i = 0; i < len; i++) { final char c = cardNumber.charAt(i); if (!Character.isDigit(c)) { throw new IllegalArgumentException(String.format("Not a digit: '%s'", c)); } final int digit = Character.digit(c, 10); sum = sum + (digit * (9 - i)); } return sum % 11 == 0; } }