You are viewing a single comment's thread. Return to all comments →
Java
public PerformOperation isOdd(){ return n -> n % 2 != 0; } public PerformOperation isPrime(){ return n -> { boolean flag = true; if(n < 2) return false; for (int i = 2; i <= n / 2; ++i) { if (n % i == 0) { flag = false; break; } } return flag; } ; } public PerformOperation isPalindrome(){ return n -> { String[] numeros = String.valueOf(n).split(""); for(int i = 0; i < Math.floor(numeros.length / 2); i++){ if(!numeros[i].equals(numeros[numeros.length-i-1])){ return false; } } return true; }; }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Lambda Expressions
You are viewing a single comment's thread. Return to all comments →
Java