Java Program to Implement Binary Search Using Recursion

In this article we are going to see how we can implement a binary search using recursion by Java programming language.

Java Program to Implement Binary Search Using Recursion

The recursive search implementation uses recursion to break the sorted array into two parts and so on, breaking until the element is found( or we reach the end).

Let’s see the program to understand it clearly.

Method-1: Java Program to Implement Binary Search Using Recursion By Using Static Input Value

Approach:

  • Create an sorted array of integers.
  • Create a variable and store the item to search.
  • Pass the array and the search item to our user defined function and store the returned index.
  • The user defined function takes the array, left and right indices and the search item as parameter. Then compare the middle element with the item. If the item is smaller, take the left part of the array, else the right part of the array and call the function on it.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
   // Recursive Binary Search
   public static int binarySearch(int arr[], int left, int right, int item)
   {
       // Check for overflow first
       if (right >= left && left <= arr.length - 1) 
       {
           // Mid is the value located in the middle
           // between the left and right indices
           int mid = left + (right - left) / 2;
           // Check if the item is at middle position
           if (arr[mid] == item)
               return mid;
           // If the item is smaller than mid
           if (arr[mid] > item)
               return binarySearch(arr, left, mid - 1, item);
           // Else if the item is larger than mid
           return binarySearch(arr, mid + 1, right, item);
        }
       // If the element is not found
       return -1;
   }

   public static void main(String[] args)
   {
       // Array to search from
       int arr[] = {10,20,25,30,40,50};
       // Item to check for in the array
       int item = 25;
       // res stores the index returned from the recursive method
       int res = binarySearch(arr,0,arr.length-1,item);
       // Print the result
       if(res == -1)
           System.out.println("The element is not found");
       else
           System.out.println("The element is at index "+res);
    }
}
Output:

The element is at index 2

Method-2: Java Program to Implement Binary Search Using Recursion By Using User Input Value

Approach:

  • Ask the user to enter the number of elements and insert the elements next.
  • Then ask the user to search for an item inside.
  • Pass the array and the search item to our user defined function and store the returned index.
  • The user defined function takes the array, left and right indices and the search item as parameter. Then compare the middle element with the item. If the item is smaller, take the left part of the array, else the right part of the array and call the function on it.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
   // Recursive Binary Search
   public static int binarySearch(int arr[], int left, int right, int item)
   {
       // Check for overflow first
       if (right >= left && left <= arr.length - 1)
       {
           // Mid is the value located in the middle
           // between the left and right indices
           int mid = left + (right - left) / 2;
           // Check if the item is at middle position
           if (arr[mid] == item)
               return mid;
           // If the item is smaller than mid
           if (arr[mid] > item)
               return binarySearch(arr, left, mid - 1, item);
           // Else if the item is larger than mid
           return binarySearch(arr, mid + 1, right, item);
        }
       // If the element is not found
       return -1;
    }

   public static void main(String[] args)
   {
       // Take user input
       Scanner sc = new Scanner(System.in);
       // Ask the user to enter array size
       System.out.print("Enter array size - ");
       int n = sc.nextInt();
       int arr[] = new int[n];
       // Ask the user to enter the array elements
       System.out.print("Enter the array elements - ");
       for(int i =0;i<n;i++)
           arr[i] = sc.nextInt();
       // Ask the user to enter an element to search
       System.out.println("Enter element to search for");
       int item = sc.nextInt();
       // res stores the index returned from the recursive method
       int res = binarySearch(arr,0,n-1,item);
       // Print the result
       if(res == -1)
           System.out.println("The element is not found");
       else
           System.out.println("The element is at index "+res);
    }
}
Output:

Enter array size - 5
Enter the array elements - 10 20 30 40 50
Enter element to search for
55
The element is not found

Don’t stop learning now. Get hold of all the important Java fundamentals with the Simple java program example guide and practice well.

Java Program to Find HCF of Two Numbers Using Recursion

In this article we are going to see how we can find HCF of two numbers using recursion by Java programming language.

Java Program to Find HCF of Two Numbers Using Recursion

HCF: 

HCF refers to the Highest Common Factor which refers to the largest common factor between 2 or more numbers.

It is also called Greatest Common Factor (GCF) or Greatest Common Divisor (GCD).

For example-

Two numbers are 2 and 4. Then the HCF is 2.
Two numbers are 30 and 42. Then the HCF is 6.

Let’s see the program to understand it clearly.

Method-1: Java Program to Find HCF of Two Numbers Using Recursion By Using Static Input Value

Approach:

  • Store two numbers in two integer variables.
  • Call the user defined method hcfCalculator( ) to find the product and store it. The method checks if either the numbers are zeroes or are equal to each other then it calculates hcf by taking modulus of the larger number and calling the method again.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to find hcf of two numbers
    public static int hcfCalculator(int num1, int num2)
    {
        // cHecks if num1 and num2 are same numbers
        if (num1 == num2) 
        {
            return num1;
        // Checks if wither of the numbers are zeroes
        } 
        else if (num1 == 0) 
        {
            return num2;
        } 
        else if (num2 == 0) 
        {
            return num1;
        // Finds the hcf using recursin
        } 
        else if (num1 > num2) 
        {
            return hcfCalculator(num1 % num2, num2);
        } 
        else 
        {
            return hcfCalculator(num1, num2 % num1);
        }
    }
    
    public static void main(String[] args)
    {
        int num1 = 39, num2 = 62;
        // Call the method and store the result
        int hcf = hcfCalculator(num1,num2);
        // Print the result
        System.out.println("The hcf of "+num1+" and "+num2+" is "+hcf);
    }
}

Output:

The hcf of 39 and 62 is 1

Method-2: Java Program to Find HCF of Two Numbers Using Recursion By Using User Input Value

Approach:

  • Ask the user to enter two numbers in order.
  • Store two numbers in two integer variables.
  • Call the user defined method hcfCalculator( ) to find the product and store it. The method checks if either the numbers are zeroes or are equal to each other then it calculates hcf by taking modulus of the larger number and calling the method again.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to find hcf of two numbers
    public static int hcfCalculator(int num1, int num2)
    {
        // cHecks if num1 and num2 are same numbers
        if (num1 == num2) 
        {
            return num1;
        // Checks if wither of the numbers are zeroes
        }
        else if (num1 == 0) 
        {
            return num2;
        }
        else if (num2 == 0) 
        {
            return num1;
        // Finds the hcf using recursin
        } 
        else if (num1 > num2) 
        {
            return hcfCalculator(num1 % num2, num2);
        } 
        else 
        {
            return hcfCalculator(num1, num2 % num1);
        }
    }
    
    public static void main(String[] args)
    {
        // Taking user input
        Scanner sc = new Scanner(System.in);
        // Ask the user to enter two numbers
        System.out.print("Enter two numbers to find HCF ");
        int num1 = sc.nextInt(), num2 = sc.nextInt();
        // Call the method and store the result
        int hcf = hcfCalculator(num1,num2);
        // Print the result
        System.out.println("The hcf of "+num1+" and "+num2+" is "+hcf);
    }
}

Output:

Enter two numbers to find HCF 10 5
The hcf of 10 and 5 is 5

Provided list of Simple Java Programs is specially designed for freshers and beginners to get familiarize with the concepts of Java programming language and become pro in coding.

Java Program to Count the Digits of a Number Using Recursion

In this article we are going to see how we can count the digits of a number using recursion by Java programming language.

Java Program to Count the Digits of a Number Using Recursion

Let’s see the program.

Method-1: Java Program to Count the Digits of a Number Using Recursion By Using Static Input Value

Approach:

  • Create a static integer variable ‘ctr’ and store any number in it.
  • Call the user defined method calcDigits( ) and store the result in an integer  variable ‘digits
  • So calcDigits( ) is an user-defined method that increments the counter and calls the method by dividing the digits by 10.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // counter to store the count
    static int ctr=0;
    // Method to count the number of digits in a number using recursion
    public static int calcDigits(int num)
    {
        // Till number is greater than zero keep on incrementing the counter
        if(num!=0)
        {
            ctr++;
            // Divides the number by 10 and recursively calls the method
            calcDigits(num/10);
        }
        return ctr;
    }
    
    public static void main(String[] args)
    {
        int num = 3962;
        // Call the method and store the result
        int digits = calcDigits(num);
        // Print the result
        System.out.println("The number of digits in "+num+" is "+digits);
    }
}
Output:

The number of digits in 3962 is 4

Method-2: Java Program to Count the Digits of a Number Using Recursion By Using User Input Value

Approach:

  • Create a static integer variable ‘ctr
  • Ask the user to enter a number and store it in an integer variable ‘num
  • Call the user defined method calcDigits( )and store the result in an integer  variable ‘digits
  • So calcDigits( ) is an user-defined method that increments the counter and calls the method by dividing the digits by 10.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // counter to store the count
    static int ctr=0;
    // Method to count the number of digits in a number using recursion
    public static int calcDigits(int num)
    {
        // Till number is greater than zero keep on incrementing the counter
        if(num!=0)
        {
            ctr++;
            // Divides the number by 10 and recursively calls the method
            calcDigits(num/10);
        }
        return ctr;
    }
    
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        System.out.print("Enter the number to calculate its digits - ");
        int num = sc.nextInt();
        // Call the method and store the result
        int digits = calcDigits(num);
        // Print the result
        System.out.println("The number of digits in "+num+" is "+digits);
    }
}
Output:

Enter the number to calculate its digits - 965
The number of digits in 965 is 3

Beginners and experienced programmers can rely on these Best Java Programs Examples and code various basic and complex logics in the Java programming language with ease.

Java Program to Multiply Two Numbers Using Recursion

In this article we are going to see how we can multiply two numbers using recursion by Java programming language.

Java Program to Multiply Two Numbers Using Recursion

Multiplying two numbers means finding the product of two numbers.

Let’s see the program how we you multiply two numbers using recursion.

Method-1:  Java Program to Multiply Two Numbers Using Recursion By Using Static Input Value

Approach:

  • Store two numbers in two variables.
  • Call the user defined method mulProd( ) to find the product and store it. The method prod() ensures that num1>num2 else swaps them. Then when num2 is greater than zero it calls mulProd( ) on num1 and decremented num2 then adds the result with num1.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to multiply two numbers
    public static int mulProd(int num1, int num2)
    {
        // If num2 is greater than num1 swap them and call the function
        if (num1 < num2) 
        {
            return mulProd(num2, num1);
        }
        // If num2 is greater than 0 then call the function by decrementing num2 by 1 and add the current num1 value to the result.
        else if (num2 != 0)
        {
            return (num1 + mulProd(num1, num2 - 1));
        }
        else 
        {
            return 0;
        }
    }
    
    public static void main(String[] args)
    {
        int num1 = 29, num2 = 10;
        // Call the method and store the result
        int prod = mulProd(num1,num2);
        // Print the result
        System.out.println("The product of "+num1+" and "+num2+" is "+prod);
    }
}

Output:

The product of 29 and 10 is 290

Method-2: Java Program to Multiply Two Numbers Using Recursion By Using User Input Value

Approach:

  • Ask the user to enter two numbers in order.
  • Store two numbers in two variables.
  • Call the user defined method mulProd( ) to find the product and store it. The method prod() ensures that num1>num2 else swaps them. Then when num2 is greater than zero it calls mulProd( ) on num1 and decremented num2 then adds the result with num1.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to multiply two numbers
    public static int mulProd(int num1, int num2)
    {
        // If num2 is greater than num1 swap them and call the function
        if (num1 < num2) 
        {
            return mulProd(num2, num1);
        }
        // If num2 is greater than 0 then call the function by decrementing num2 by 1 and add the current num1 value to the result.
        else if (num2 != 0) 
        {
            return (num1 + mulProd(num1, num2 - 1));
        }
        else 
        {
            return 0;
        }
    }
    
    public static void main(String[] args)
    {
        // Taking user input
        Scanner sc = new Scanner(System.in);
        // Ask the user to enter two numbers
        System.out.print("Enter two numbers to multiply ");
        int num1 = sc.nextInt(), num2 = sc.nextInt();
        // Call the method and store the result
        int prod = mulProd(num1,num2);
        // Print the result
        System.out.println("The product of "+num1+" and "+num2+" is "+prod);
    }
}
Output:

Enter two numbers to multiply 15 50
The product of 15 and 50 is 750

Access the Simple Java program for Interview examples with output from our page and impress your interviewer panel with your coding skills.

Java Program to Subtract Two Numbers Using Recursion

In this article we are going to see how we can subtract two numbers using recursion by Java programming language.

Java Program to Subtract Two Numbers Using Recursion

Method-1: Java Program to Subtract Two Numbers Using Recursion By Using Static Input Value

Approach:

  • Store two numbers in two variables.
  • Call the user defined method sub( ) to find the difference and store it. The method sub() decrements both the numbers by 1 using recursion until the smaller one reaches 0. Then it returns the other number.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to subtract two numbers
    public static int sub(int num1, int num2)
    {
        // Returns the difference when num2 reaches zero
        if(num2==0)
            return num1;
        else
            // calls the function by decrementing both numbers by 1
            return sub((num1-1),(num2-1));
    }
    
    public static void main(String[] args)
    {
        int num1 = 29, num2 = 15;
        // Call the method and store the result
        int dif = sub(num1,num2);
        // Print the result
        System.out.println("The difference between "+num1+" and "+num2+" is "+dif);
    }
}
Output:

The difference between 29 and 15 is 14

Method-2: Java Program to Subtract Two Numbers Using Recursion By Using User Input Value

Approach:

  • Ask the user to enter two numbers in order.
  • Store two numbers in two variables.
  • Call the user defined method sub( ) to find the difference and store it. The method sub() decrements both the numbers by 1 using recursion until the smaller one reaches 0. Then it returns the other number.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to subtract two numbers
    public static int sub(int num1, int num2)
    {
        // Returns the difference when num2 reaches zero
        if(num2==0)
            return num1;
        else
        // calls the function by decrementing both numbers by 1
            return sub((num1-1),(num2-1));
    }
    
    public static void main(String[] args)
    {
        // Taking user input
        Scanner sc = new Scanner(System.in);
        // Ask the user to enter two numbers
        System.out.print("Enter two numbers to subtract ");
        int num1 = sc.nextInt(), num2 = sc.nextInt();
        // Call the method and store the result
        int dif = sub(num1,num2);
        // Print the result
        System.out.println("The difference between "+num1+" and "+num2+" is "+dif);
    }
}
Output:

Enter two numbers to subtract 10 5
The difference between 10 and 5 is 5

Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list is mandatory.

Java Program to Find the Length of a String Using Recursion

In this article we are going to see how we can find the length of a string using recursion by Java programming language.

Java Program to Find the Length of a String Using Recursion

The length of the string refers to the total number of characters present in that.

For example-

A string is "BtechGeeks"
Then in this string there are 10 characters. So length of string is 10.

Let’s see the program to find the length of a string using recursion.

Method-1: Java Program to Find the Length of a String Using Recursion By Using Static Input Value

Approach:

  • Store a string.
  • Store the string and call the user-defined method strLen( ) passing the string as parameter.
  • The user defined method checks if we have reached the end, else it recursively calls itself on the same string without the current character and adds 1 to the result.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to calculate string length
    public static int strLen(String s)
    {
        // Checks if we have reached the end of the string
        if (s.equals(""))
            return 0;
        else
            // Calls function on a substring not including the current character
            return strLen(s.substring(1)) + 1;
    }
    
    public static void main(String[] args)
    {
        String s = "Hi!!!";
        // Call the method and store the length
        int length = strLen(s);
        // Print the result
        System.out.println("The number of characters in the string "+s+" is "+length);
    }
}
Output:

The number of characters in the string Hi!!! is 5

Method-2: Java Program to Find the Length of a String Using Recursion By Using User Input Value

Approach:

  • Ask the user to input a string.
  • Store the string and call the user-defined method strLen( ) passing the string as parameter.
  • The user defined method checks if we have reached the end, else it recursively calls itself on the same string without the current character and adds 1 to the result.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to calculate string length
    public static int strLen(String s)
    {
        // Checks if we have reached the end of the string
        if (s.equals(""))
            return 0;
        else
            // Calls function on a substring not including the current character
            return strLen(s.substring(1)) + 1;
    }
    
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        // Ask the user to input the string
        System.out.print("Enter the string - ");
        String s = sc.nextLine();
        // Call the method and store the length
        int length = strLen(s);
        // Print the result
        System.out.println("The number of characters in the string "+s+" is "+length);
    }
}
Output:

Enter the string - helloworld!
The number of characters in the string helloworld! is 11

Want to excel in java coding? Practice with these Java Programs examples with output and write any kind of easy or difficult programs in the java language.

Java Program to Check If a Number is Prime or Not Using Recursion

In this article we are going to see how we can check if a number is prime or not using recursion by Java programming language.

Java Program to Check If a Number is Prime or Not Using Recursion

A number is said to be prime number if it has only 2 factors i.e. 1 and the number itself. Means other than 1 and itself it is not divisible by any other numbers.

For example- 7, 13, 19, 29 etc.

Here you have to write the program check if a number is prime or not using recursion.

Method-1: Java Program to Check If a Number is Prime or Not Using Recursion By Using Static Input Value

Approach:

  • Declare an Integer variable ‘num’ and initialize with 59.
  • Call the user defined method checkPrime( ) by passing the ‘num’ and its half.
  • The user-defined method takes a ‘num’ and its half as input. Then keeps on decrementing the half until it divides the ‘num‘ or it reaches 1 using recursion.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to check for prime
    public static int checkPrime(int num, int i)
    {
        if (i != 1) 
        {
            // checks if the number is divisible
            if (num % i != 0) 
            {
                // Decrements the divisor by 1 every call
                return checkPrime(num, i - 1);
            }
            else 
            {
                return 0;
            }
        }
        else 
        {
            return 1;
        }
    }
    
    public static void main(String[] args)
    {
        int num = 59;
        // Call the method and store the result
        int res = checkPrime(num,num/2);
        // Print the result
        if(res==1)
            System.out.println(num+" is prime.");
        else
            System.out.println(num+" is not prime.");
    }
}
Output:

59 is prime.

Method-2: Java Program to Check If a Number is Prime or Not Using Recursion By Using User Input Value

Approach:

  • Ask the user to enter a number and store it in ‘num‘ variable.
  • Call the user defined method checkPrime( ) by passing the ‘num‘ and its half.
  • The user-defined method takes a ‘num‘ and its half as input . Then keeps on decrementing the half until it divides the ‘num‘ or it reaches 1 using recursion.
  • Print the result.

Program:

import java.util.*;
// Main class
public class Main
{
    // Recursive method to check for prime
    public static int checkPrime(int num, int i)
    {
        if (i != 1) 
        {
            // checks if the number is divisible
            if (num % i != 0) 
            {
                // Decrements the divisor by 1 every call
                return checkPrime(num, i - 1);
            }
            else 
            {
                return 0;
            }
        }
        else 
        {
            return 1;
        }
    }
    
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        // Asks the user for input
        System.out.println("Enter a number");
        int num = sc.nextInt();
        // Call the method and store the result
        int res = checkPrime(num,num/2);
        // Print the result
        if(res==1)
            System.out.println(num+" is prime.");
        else
            System.out.println(num+" is not prime.");
    }
}
Output:

Enter a number
153
153 is not prime.

Grab the opportunity to learn all effective java programming language concepts from basic to advance levels by practicing these Java Program Examples with Output.

Java LocalDate getDayOfMonth() Method with Examples

In this article we are going to see the use of Java LocalDate class getDayOfMonth() method with suitable examples.

Java LocalDate getDayOfMonth() Method with Examples

Explanation:

This java.time.LocalDate.getDayOfMonth() method is used to get the day of the month which date is given by the user. It returns the day of the month which is from 1 to 31.

Syntax:

public int getDayOfMonth()

Let’s see some example programs to understand it more clearly.

Approach:

  • Create an object of localDate class.
  • Then use the getDayOfMonth() method for this particular date to extract the day of that month.
  • Print the final result.

Example-1:

import java.time.LocalDate;
public class Main
{
    public static void main(String[] args)
    {
        //Create an object of LocalDate class and assign a date to it
        //here it parses the local date
        LocalDate date = LocalDate.parse("2022-05-11");
        //use the getDayOfMonth() method and print the result
      	System.out.println("Day-of-the-month: "+date.getDayOfMonth()); 
    }
}
Output:

Day-of-the-month: 11

Example-2:

import java.time.LocalDate;
public class Main
{
    public static void main(String[] args)
    {
        //Create an object of LocalDate class and assign a date to it
        //here it parses the local date
        LocalDate date = LocalDate.parse("2022-05-29");
        //use the getDayOfMonth() method and print the result
          System.out.println("Day-of-the-month: "+date.getDayOfMonth()); 
    }
}
Output:

Day-of-the-month: 29

Are you wondering how to seek help from subject matter experts and learn the Java language? Go with these Basic Java Programming Examples and try to code all of them on your own then check with the exact code provided by expert programmers.

Java LocalDate getDayOfWeek() Method with Examples

In this article we are going to see the use of Java LocalDate class getDayOfWeek() method with suitable examples.

Java LocalDate getDayOfWeek() Method with Examples

Explanation:

This java.time.LocalDate.getDayOfWeek() method is used to get the day of the week which date is given by the user. It returns the day of the week which is from Sunday to Saturday.

Syntax:

public DayOfWeek getDayOfWeek()

Let’s see some example programs to understand it more clearly.

Approach:

  • Create an object of localDate class.
  • Then use the getDayOfWeek() method for this particular date to print the day of that week.
  • Print the final result.

Example-1

import java.time.LocalDate;
public class Main
{
    public static void main(String[] args)
    {
        //Create an object of LocalDate class and assign a date to it
        //here it parses the local date
        LocalDate date = LocalDate.parse("2022-05-11");
        //Use the getDayOfWeek() method and print the result
        System.out.println("Day-of-the-week: "+date.getDayOfWeek()); 
    }
}


Output:

Day-of-the-week: WEDNESDAY

Example-2

import java.time.LocalDate;
public class Main
{
    public static void main(String[] args)
    {
        //Create an object of LocalDate class and assign a date to it
        //here it parses the local date
        LocalDate date = LocalDate.parse("2022-05-29");
        //Use the getDayOfWeek() method and print the result
        System.out.println("Day-of-the-week: "+date.getDayOfWeek()); 
    }
}
Output:

Day-of-the-week: SUNDAY

If you are new to Java and want to learn the java coding skills too fast. Try practicing the core java programs with the help of the Java basic programs list available.

Java LocalDate getChronology() Method with Examples

In this article we are going to see the use of Java LocalDate class getChronology()  method with suitable examples.

Java LocalDate getChronology() Method with Examples

Explanation:

This java.time.LocalDate.get(TemporalField field) method is used to get the chronology of the specified date, which is the ISO calendar system. This method does not take any parameter. It returns the ISO chronology.

Syntax:

public IsoChronology getChronology()

Let’s see a program to understand it more clearly.

Approach:

  • Create an objectof LocalDate class which will hold the parsed date.
  • Then use the getChronology() method for this particular date.
  • Print the final result.

Program:

import java.time.LocalDate;
public class Main
{
    public static void main(String[] args)
    {
        //create an object of LocalDate and pass the parse date into it
        //here it parses the local date
        LocalDate date = LocalDate.parse("2022-05-11");
        //print the result
      	System.out.println("Result: "+date.getChronology()); 
   	}
}

Output:

Result: ISO

The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples as it includes basic to advanced levels of concepts.