Code Examples
A repository of 155 code examples for BeepBeep
functions.IsPrime Class Reference

Create a custom unary function that checks if a number is prime. More...

Public Member Functions

Boolean getValue (Number x)
 

Static Public Member Functions

static void main (String[] args) throws FunctionException
 

Static Public Attributes

static final transient IsPrime instance = new IsPrime()
 This is optional. More...
 

Detailed Description

Create a custom unary function that checks if a number is prime.

Instead of inheriting from the top-level Function class, it is easier in most cases to descend from lower classes, which provide a few more functionalities. For a function that takes a single argument, it is wise to extend UnaryFunction.

Author
Sylvain Hallé

Definition at line 33 of file IsPrime.java.

Member Data Documentation

◆ instance

final transient IsPrime functions.IsPrime.instance = new IsPrime()
static

This is optional.

Since a Function object is stateless, the same instance can be used everywhere it is needed. Therefore, it is recommended to enforce the existence of a single instance by making the function's constructor private, and by making public a static field pointing to an instance of the function. By convention, you are encouraged to use the name "instance" for this field.

Definition at line 44 of file IsPrime.java.


The documentation for this class was generated from the following file: