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.
public static PerformOperation is_odd() {
return (int a) -> {
return ((a & 1) == 1);
};
}
public static PerformOperation is_prime() {
return (int a) -> {
if (a < 2) return false;
for (int i = 2; i * i <= a; i++)
if (a % i == 0) return false;
return true;
};
}
public static PerformOperation is_palindrome() {
return (int a) -> {
String str = Integer.toString(a);
String str2 = "";
int i = 0;
int j = str.length() - 1;
for ( ; i <= j; ++i, --j) {
if (str.charAt(i) != str.charAt(j)) return false;
}
return true;
};
}
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 →