We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
i had the same problem, but the code below worked just fine.
public static PerformOperation isOdd(){ return (int a) -> a % 2 != 0; }
public static PerformOperation isPrime(){
return (int a) -> java.math.BigInteger.valueOf(a).isProbablePrime(1);
}
public static PerformOperation isPalindrome(){
return (int a) -> Integer.toString(a).equals( new StringBuilder(Integer.toString(a)).reverse().toString() );
}
Cookie support is required to access HackerRank
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 →
i had the same problem, but the code below worked just fine.
public static PerformOperation isOdd(){ return (int a) -> a % 2 != 0; }
public static PerformOperation isPrime(){ return (int a) -> java.math.BigInteger.valueOf(a).isProbablePrime(1); }
public static PerformOperation isPalindrome(){ return (int a) -> Integer.toString(a).equals( new StringBuilder(Integer.toString(a)).reverse().toString() ); }