![]() |
| Add caption |
A Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println method, for example, the system actually executes several statements in order to display a message on the console.
Now you will learn how to create your own methods with or without
return values, invoke a method with or without parameters, overload
methods using the same names, and apply method abstraction in the
program design.

Java methods are helpful for more flexible codes.
ReplyDeleteA Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println method, for example, the system actually executes several statements in order to display a message on the console.
ReplyDeleteNow you will learn how to create your own methods with or without return values, invoke a method with or without parameters, overload methods using the same names, and apply method abstraction in the program design.
ryt princess, but is there any further more explanations?
DeleteJava Methods are very great and exciting to write. Through methods, we are able to discern the most significant concept of OOP which is code reuse. Haha.
ReplyDeletenow i know how to create methods..........<3
ReplyDeleteyeah. It's very simple and helpful.
Deletethis is so useful...good job!
ReplyDeletei understand it. nice.
ReplyDeletejust click this link to know more . :)
http://www.tutorialspoint.com/java/java_methods.htm
The method declaration is the first line, or header, of a method. It contains the
ReplyDeletefollowing:
» Optional access modifiers
» The return type for the method
» The method name
» An opening parenthesis
» An optional list of method parameters (you separate multiple parameters
with commas)
» A closing parenthesis
Method in Java is a little bit complex.
ReplyDeleteThis comment has been removed by the author.
ReplyDeletejava method is very helpful especially in complicated codes.. you can reuse this method.
ReplyDeleteExample for java method:
ReplyDeleteHere is the source code of the above defined method called max(). This method takes two parameters num1 and num2 and returns the maximum between the two:
/** Return the max between two numbers */
public static int max(int num1, int num2) {
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
in naming a method , a method can be any legal identifier, code conventions restrict method names.
ReplyDeleteah... + AND IN CONVENTION, METHOD names should be a verb in lower case or a multi-word name that begins with a verb in lower case, followed by adjectives,nouns,etc.
DeleteThis comment has been removed by the author.
ReplyDeletecool.....guys..to know more about java methods, you can check out this link....
ReplyDeletehttp://www.tutorialspoint.com/java/java_methods.htm
hope it's helpful..
Here is the source code of the above defined method called max(). This method takes two parameters num1 and num2 and returns the maximum between the two:
ReplyDelete/** Return the max between two numbers */
public static int max(int num1, int num2) {
int result;
if (num1 > num2)
result = num1;
else
result = num2;
return result;
}
In creating a method, you give a definition of what the method is to do. To use a method, you have to call or invoke it. There are two ways to call a method; the choice is based on whether the method returns a value or not.
ReplyDeletecreating a method
ReplyDeletecalling a method ..
fr more info , visit this link, . java tutorial is also available :) keep smiling
http://www.tutorialspoint.com/java/java_methods.htm
hey guys.. check this for the tutorial in methods..
ReplyDeletehttp://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
http://www.homeandlearn.co.uk/java/java_method_calling.html
*hope it can help. :))
a method must include the ff:
ReplyDelete- a declaration
- an opening curly braces
- body
- closing curly braces
A java method is a series of statements that perform some repeated task. Instead of writing 10 lines of code we can put those ten lines in a method and just call it in one line. It is like a shortcut.
ReplyDeleteTwo types of Methods are static and instance.
ReplyDeleteIn static you can code it inside the class file and can be use by just calling the method. The instance is in another class file that when called it is put into an object that will be use to when calling the method. :)
methods are very useful and easy to understand.
ReplyDeletethis link might help us in understandinf methods..
Deletehttp://www.tutorialspoint.com/java/java_methods.htm
The access modifier for Java method can be any of the following modifiers:
ReplyDeletePublic, private, protected or if left unspecified, package.
Java methods is AMAZING.. It is very helpful in creating codes...
ReplyDeleteWithout a method you cannot perform an operation.
ReplyDeleteJava Method
ReplyDeleteA method is a set of code which is referred to by name and can be called (invoked) at any point in a program simply by utilizing the method's name. Think of a method as a subprogram that acts on data and often returns a value.
:)
method in java have six components...it helps a lot
Deleteagreed... :-)
Deleteit can make our code short..
ReplyDeletenice that there are methods to follow but still we need more time to master those methods
ReplyDeleteJava Method
ReplyDeleteA method is an operation on a particular object. An object is an instance of a class. When we define a class we define its member variables and its methods. For each method we need to give a name, we need to define its input parameters and we need to define its return type.
clone() is a method in the Java programming language for object duplication. In Java, objects are manipulated through reference variables, and there is no operator for copying an object—the assignment operator duplicates the reference, not the object. The clone() method provides this missing functionality.
this link will lead you into an example on how to call JAVA methods
ReplyDeletehttp://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/method.html
Java method is a collection of statements that are grouped together to perform an operation. When you call the System.out.println method, for example, the system actually executes several statements in order to display a message on the console.
ReplyDeletehttp://www.tutorialspoint.com/java/java_methods.htm
ReplyDeletejust check this site guys..it is very help of full..:)
A method definition consists of a method header and a method body. Here are all the parts of a method:
ReplyDeleteModifiers: The modifier, which is optional, tells the compiler how to call the method. This defines the access type of the method.
Return Type: A method may return a value. The returnValueType is the data type of the value the method returns. Some methods perform the desired operations without returning a value. In this case, the returnValueType is the keyword void.
Method Name: This is the actual name of the method. The method name and the parameter list together constitute the method signature.
Parameters: A parameter is like a placeholder. When a method is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a method. Parameters are optional; that is, a method may contain no parameters.
Method Body: The method body contains a collection of statements that define what the method does.