Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 18-08-2009
Member
 
Join Date: Jun 2009
Posts: 758
Methods in JAVA

I am new to JAVA and its php codes. While working on Java from last coule of days, i came to know there are some methods in JAVA.

To be frank i don't have any idea about these methods.

Could you guys please explain me what are these methods in JAVA ? Thanks in advance.
Reply With Quote
  #2  
Old 18-08-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Methods in JAVA

A method is a group of instructions that is given a name and can be called up at any point in a program simply by quoting that name. You can also call Java method as a set of Java statements which can be included inside a Java class.Here is an example of a typical method declaration:
Code:
public double calculateAnswer(double wingSpan, int numberOfEngines, double length, double grossTons) {
	//do the calculation here
}
Although a method name can be any legal identifier, code conventions restrict method names. By convention, method names should be a verb in lowercase or a multi-word name that begins with a verb in lowercase, followed by adjectives, nouns, etc. In multi-word names, the first letter of each of the second and following words should be capitalized.
Reply With Quote
  #3  
Old 18-08-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Methods in JAVA

The method is called by the statement calculation(). Every Java program must have one main() method because they are similar to functions or procedures in other programming languages.The only required elements of a method declaration are the method's return type, name, a pair of parentheses, (), and a body between braces, {}. More generally, method declarations have six components, in order:
  • Modifiers—such as public, private, and others you will learn about later.
  • The return type—the data type of the value returned by the method, or void if the method does not return a value.
  • The method name—the rules for field names apply to method names as well, but the convention is a little different.
  • The parameter list in parenthesis—a comma-delimited list of input parameters, preceded by their data types, enclosed by parentheses, (). If there are no parameters, you must use empty parentheses.
  • An exception list—to be discussed later.
  • The method body, enclosed between braces—the method's code, including the declaration of local variables, goes here.
Reply With Quote
  #4  
Old 18-08-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Methods in JAVA

The idea of methods appears in all programming languages, although sometimes it goes under the name functions and sometimes under the name procedures.The Java programming language supports overloading methods, and Java can distinguish between methods with different method signatures. This means that methods within a class can have the same name if they have different parameter lists.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Methods in JAVA"
Thread Thread Starter Forum Replies Last Post
Identify active methods in java Maya Angelou Software Development 4 06-04-2010 01:53 PM
What is Export Methods in Java? NIcaBoy Software Development 4 13-02-2010 06:29 AM
Explain the difference between == & .equals methods in Java? Harpreet Gaur Software Development 5 30-01-2010 11:36 AM
Native methods of java Truster Software Development 5 22-01-2010 10:52 AM
join() and isAlive() methods of java Owen Fernandes Software Development 5 21-01-2010 08:28 AM


All times are GMT +5.5. The time now is 01:01 AM.