Results 1 to 4 of 4

Thread: Methods in JAVA

  1. #1
    Join Date
    Jun 2009
    Posts
    761

    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.

  2. #2
    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.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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.

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,008,160.73230 seconds with 17 queries