Saturday, July 22, 2023

Static function in java

How to call a method in main without creating object in Java ?

public class Staticfunc {

    static void f()          //Static keyword is used as the f() is called in main method without object.

    {

        System.out.println("Sunday");

    }

    public static void main(String[] args) {

        System.out.println("Monday");

        f();

        System.out.println("friday");

    } 

No comments:

Post a Comment

Complete Works of Swami Vivekananda [Volume 8,Page - 2069]

  Complete Works of Swami Vivekananda [ Volume 8, Page - 2069] Jesus Christ was God — the Personal God become man. He has manifested Himsel...