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

A physicist confesses that the electron is round and that Jesus rose from the dead. (Bengali)

একজন পদার্থবিজ্ঞানী স্বীকার করেন যে ইলেকট্রন গোলাকার এবং যিশু মৃতদের মধ্য থেকে পুনরুত্থিত হয়েছিলেন। আমার নিজের বিশ্বাস প্রমাণ দ্বারা প্রভাব...