Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

instance methods

  Asked By: Harley    Date: Apr 23    Category: Java    Views: 593
  

i'm new to programming with java and i am writing a program with
two classes. In the GUI class i have to call methods from my second
class to output the results, but the methods are instance methods.
So i do not know how to call the instance method, because they are
not static type. This is probably a very basic question, but my
textbook does not describe this and i have looked at all kind of
resources including the sun microsystems tutorial and cannot find
the syntax for calling the instance methods anywhere. thank you

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Rochelle Elliott     Answered On: Apr 23

instance method:
String s = new String("Good");
char c = s.charAt(2);

static:
String.toValue(4);

The difference is that you need to create an object of a class  frist
before you can call  an instace method  of it.\then you need to call
the objects instance  methos, as described above. Static methods  you
don't need to do this. Instead of saying <class>.<method>() it is
<object handle>.<method>()

 
Answer #2    Answered By: Silvia Chapman     Answered On: Apr 23

maybe this would help you too:

...
new YourClass().instanceMethod();

 
Answer #3    Answered By: Ty Thompson     Answered On: Apr 23

What is instance  method?

Actually, we can access a class  methoc by instantiate the class and
then call  the method.
Sample:

new Second().theMethod();

 
Answer #4    Answered By: Grady Stewart     Answered On: Apr 23


May be instance  method mean you must have to instanciate the class  for use
his methods.

 
Didn't find what you were looking for? Find more on instance methods Or get search suggestion and latest updates.




Tagged: