Hi,
I just wanted to know about instance method? If static modifier is not applied before does it makes it an instance method ? Plz give an example
Thanku

Recommended Answers

All 2 Replies

public class Bird {
    ....
    ....

    /*static method*/
    public static void eat() {
    }

    /*instance method*/
    public void fly() {
    }
}

so inside your main

Bird myBird=new Bird();

/* call instance method */
myBird.fly();

/*call static method*/
Bird.eat();

see how instance methods need an object to be called?? and static methods do not need objects

why did you need a second thread with an exact same question ?
yes, if a variable or a method are not declared as being static, they are instance variables/methods.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.