Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.function.Predicate;

public class Main {

    public static void main(String[] args) {
        Predicate<Integer> prime = (value) -> {
            if (value <= 2) {
                return (value == 2);
            }
            for (long i = 2; i * i <= value; i++) {
                if (value % i == 0) {
                    return false;
                }
            }
            return true;
        };

        System.out.println("Primzahl 1: " + prime.test(1));
        System.out.println("Primzahl 1: " + prime.test(3));
    }

}