Saturday, July 22, 2023

Non-static Function in JAVA

How to call a function in main by creating object in java ?

 public class NonStaticFunc {

    void f()
    {
        System.out.println("Sunday");
    }
    public static void main(String[] args) {
        NonStaticFunc ob=new NonStaticFunc();
        System.out.println("Monday");
        ob.f();
        System.out.println("Friday");
    }
}
// Static keyword is not used here as object is created.//

No comments:

Post a Comment

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

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