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

Newbie question

Tom Schuman

Joined: Dec 30, 2004
Posts: 18
What does implementing a method mean? Is it same as using it? Or is it to write a method in a class?

I speak finnish as my mother tongue and when i checked a English-Finish dictionary it says implement is same as a tool
[ February 24, 2005: Message edited by: Tom Schuman ]
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
When ever any class implements an interface or when ever a non abstract class extends a abstract class, the class should implement ( in other words define ) the methods in the interface or define the abstract methods in the superclass.

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Tom Schuman

Joined: Dec 30, 2004
Posts: 18
So it's basically adding statements to an empty method(abstract method?) so that it does something. Is it also called implementing when you write those statements when you make the method?
Lionel Badiou
Ranch Hand

Joined: Jan 06, 2005
Posts: 140
Hello Tom,

Before using a method (or simply call it), you must:

1 - Declare it : this states the method name, its input arguments and outpout return (and sometimes what exceptions it may throw).

2 - Define it : this express what the method really does using java syntax.

Interfaces declare methods but never define them. So basically, you can consider "implementing a method" as a synonym for "defining a method".

Hope that helps,
(By the way, I like very much Finland ! )

Lionel Badiou
CodeFutures Software
Tom Schuman

Joined: Dec 30, 2004
Posts: 18
Now i understand it
Thx alot Srinvasa and Linonel
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Just a few variations on the language for examples ...

ArrayList implements the List interface

ArrayList implements the size() method required by the interface

ArrayList is an implementation of List

An interface like List is "abstract"

An implementing class like ArrayList is "concrete" (unless it uses the "abstract" keyword)

As one of those lower life forms with only one language I admire all you folks who communicate in many. Never be afraid to ask what new things mean.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
If I may add my two cents, the word "to implement" also has another general meaning in programming. If you implement an algorithm or a method, it just means that you write the code for it.

Also, the dictionary you used is correct. The word "implement" can also be used as a noun to refer to any kind of tool. However, in this conversation, we are typically using the word as a verb instead.


Java API Documentation
The Java Tutorial
Tom Schuman

Joined: Dec 30, 2004
Posts: 18
I have an another question:

What do you exactly do when you override a method? I know it's something about changing what the method does.

Could someone give me a small code example where you first create a method and then override it? That would help me alot.
marc weber

Joined: Aug 31, 2004
Posts: 11343

An overridden method is one that has a different implementation than a method of the same signature in the parent class.

For example, the code below defines a method in a base class, then an extended class inherits from that base class and overrides the method to do something else.

The interesting (and useful) thing about this is polymorphism: The method is invoked based on the true runtime type of the object. For example, if an extended object is upcast to its base type, the extended method will still be invoked...

(For more information, search the forums for "polymorphism.")

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Newbie question
jQuery in Action, 3rd edition