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

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...