File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes what does Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "what does "method" mean?????" Watch "what does "method" mean?????" New topic

what does "method" mean?????


Joined: Dec 25, 2000
Posts: 6
i am form israel and i donot understand what does
"method" mean
why does every body explian using the word"method" in the
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
A method is a piece of code that's used to perform some specific functionality. It may or may not return a value. And it may/may not tke parameters. Depending on how it is declared, it could also be used in different classes. It's the similar to procedures/functions in languages such as C/C++, and VB.
I hope this helps.

So much trouble in the world -- Bob Marley
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
Please note that The Java Ranch has a naming policy, described here and "hp2500cp" is not a valid name.
Please choose one which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
The term "method" comes from traditional object-oriented theory. An object performs actions by being sent "messages". Each message is processed by the language system to decide which "method" to dispatch it to. Languages such as Smalltalk make a clear distinction between the concepts of "message" and "method", but in Java it's not quite so obvious that they can be different.
Imagine two classes, as follows:

As you can see, we have three methods: doit(String) and doit() in A and doit(String) in B. An object of either of the classes can respond to two messages doit() and doit(String)
Imagine we have an object of class B (let's call it "b"). If we send the message "doit()" to our object by writing "b.doit()", the system does the following steps:
1. Does the class of the object have a method matching the message "doit()"? The answer is no, so ...
2. Does the superclass of the object have a method matching the message "doit()"? The answer is yes, so ...
3. Execute the method.
In a "late-binding" language such as Smalltalk, this whole process is actually performed at runtime, but in Java, this process can sometimes be performed when the files are compiled.
I agree. Here's the link:
subject: what does "method" mean?????
It's not a secret anymore!