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.
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:
hey nice !!
keep it up yaar !!
it was really useful
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();
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!
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
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!
Post a Comment
Subscribe to Post Comments [Atom]
<< Home