interface Numbers
{ public abstract boolean checkFactor(int n, int m); }
public class LambdaFactor
{
public static void main(String[] args)
{
java.util.Scanner scan = new java.util.Scanner(System.in);
Numbers factor = (n, m) -> (n%m)==0;
System.out.println("Enter two numbers: ");
int n = scan.nextInt(); int m = scan.nextInt();
System.out.println(m + " is a factor of " + n + ": " + factor.checkFactor(n, m));
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter