Programming Code Center(PCC)
[JAVA]

(PCC)::[How-to-write-Java-Program-to-Display-Prime-Numbers-Between-Intervals-Using-Function]::[java]

File Name : PrimeNew1.java

//Example: Prime Numbers Between Two Integers
public class PrimeNew1 {

    public static void main(String[] args) {

        int low = 20, high = 50;

        while (low < high) {
            if(checkPrimeNumber(low))
                System.out.print(low + " ");

            ++low;
        }
    }

    public static boolean checkPrimeNumber(int num) {
        boolean flag = true;

        for(int i = 2; i <= num/2; ++i) {

            if(num % i == 0) {
                flag = false;
                break;
            }
        }

        return flag;
    }
}

Output :

PrimeNew1.jpg