Results 1 to 6 of 6
  1. #1
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default functional/procedureal Methods

    In one of my computer science modules it explains that a procedural method "cause one or more actions to occur from within the method" and "may receive values when invoked / called " and a functional method "performs a calculation and returns a result / value". What does this actually mean? When the assignment asks me to use procedural method, what is it asking for?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    a procedural method and functional method are very similar except that the procedural method returns nothing. When you define it, you state that it returns "void" or nothing. For instance:

    Procedural method:
    Java Code:
    public void printMyName(String name)
    {
      System.out.println("My name is " + name);
    }
    Functional method:
    Java Code:
    public int calcMyAge(int yearOfBirth, int currentYear)
    {
      return currentYear - yearOfBirth; // must return an int result
    }

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    (this brings back memories of my Turbo Pascal and Delphi days)

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default

    I think those words are rarely used in Java. But in C/C++ it's used. I hope there is no huge different at all, isn't it, except that return something or not.

  5. #5
    leiferouis is offline Member
    Join Date
    Jan 2009
    Posts
    31
    Rep Power
    0

    Default

    Thanks for the help. I guess when they are asking me to do the assignment with functional methods, they mean to use code that will return values?

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. Replies: 8
    Last Post: 04-16-2012, 11:00 PM
  2. Non functional radio buttons and messed up array
    By flameofSuzaku in forum New To Java
    Replies: 2
    Last Post: 01-10-2011, 05:38 PM
  3. Get and Set Methods
    By kian_hong2000 in forum New To Java
    Replies: 10
    Last Post: 08-27-2008, 02:06 PM
  4. JSP methods example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-30-2008, 10:00 AM
  5. methods
    By Zensai in forum New To Java
    Replies: 10
    Last Post: 12-03-2007, 05:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •