what is method signature ? write a simple program c=a+b by using method signature?
Printable View
what is method signature ? write a simple program c=a+b by using method signature?
You can't ... because a signature is only part of writing a method.
A method's "signature" is its declaration:
public int calcC( int a, int b)
it tells the user that in order to calculate C, you pass the calcC method two int arguments, and the method returns an int value to the calling method.
If your user's only knowledge of this method is its signature, she knows how to use it. In this way, it is a part of the "interface" to your class. Take a look at the Java API documentation - each class's Javadocs content includes the signatures of the methods, not the body or definition of the methods.
The programmer still needs to define the method - to write the series of statements which carry out this calcC. This can remain hidden or obscured - the user doesn't need to know the implementation details in order to use the method.