Friday, February 29, 2008

Calling a Method in Java Program

Calling a method in Java mainly involves of two basic steps:

1. You have to create an object to the class to which the method belongs.

Syntax for the above step : Classname obj = new Classname();

Example: First f = new First();

Here "First" is the classname and 'f' is the object created to that class.

2.Now after creating an object you can call any method using the notation "object.methodname();"

Therefore for the above example the calling goes like this : 'f.method'.

Here 'f' is the object we created.

5 Comments:

Anonymous Anonymous said...

hey nice !!
keep it up yaar !!
it was really useful

August 21, 2008 at 10:51 AM  
Anonymous Alberto said...

Of course, this is only true of non-static methods. What if you'd like to call a static method?

In that case, creating an object is not required, so with your example all you would have to do to call a static method is:

First.methodname();

September 24, 2009 at 9:58 AM  
Anonymous Anonymous said...

Who knows where to download XRumer 5.0 Palladium?
Help, please. All recommend this program to effectively advertise on the Internet, this is the best program!

November 14, 2009 at 5:33 AM  
Anonymous Anonymous said...

Great blog as for me. I'd like to read a bit more about that theme. Thnx for posting that data.
Sexy Lady
Blonde escorts UK

December 18, 2009 at 5:02 AM  
Blogger Emime said...

hey check this new website www.countcode.com. It's a social network made for programmers, where you can download,share or upload source codes, where you can count your own code lines for free. You have access to the web forum and the web chatroom. we are happy to have you joined to our community!

April 28, 2012 at 11:49 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home