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

Interference in Light vs Quantum States

🔬 The Double-Slit Experiment: Where It All Begins One of the most famous demonstrations of interference is the double-slit experiment. When...