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

Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, contact manager, note-taking, journal, and web browsing

 Outlook, developed by Microsoft, is a widely used personal information manager that includes an email client, calendar, task manager, conta...