Static Member Function in Java

This Java code defines a class Mathematical with a static method power, which takes two integer arguments base and power and returns the result of raising base to the powerth power.

The class staticExample contains the main method, which is the entry point of the program. In the main method, the power method of the Mathematical class is called with the arguments 2 and 3, and the result is printed to the console using System.out.println.

Source Code

class Mathematical {
    public static int power(int base, int power) {
        int result = 1;
        for (int i = 1; i <= power; i++) {
            result *= base;
        return result;
public class staticExample {
    //Static Member Function in Java
    public static void main(String args[]) {
        System.out.println("Power : " + Mathematical.power(2, 3));


Power : 8
To download raw file Click Here

Basic Programs