Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Function or method?  (Read 1504 times)
0 Members and 1 Guest are viewing this topic.
the_jogler
Guest
« Posted 2007-09-02 01:32:54 »

This is probably better suited to my other thread about the return statement, but this is a new (quick) question, so I'm just going to put it here. Real quick, is a function the same as a method or are they different? Thanks.
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #1 - Posted 2007-09-02 03:29:35 »

There are no functions in Java only methods.

Basically... functions and methods are the same. The difference is that methods are always bound to objects. So, you got functions in functional languages and methods in OO languages.

弾幕 ☆ @mahonnaiseblog
Offline quixote_arg

Junior Member


Projects: 1


Jengibre


« Reply #2 - Posted 2007-09-02 03:46:10 »

technically, a function always returns the same value so

1  
2  
3  
public Date now() {
   return new Date();
}


is not a function, but that's just a formality
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline JAW

Senior Member


Medals: 2



« Reply #3 - Posted 2007-09-14 10:00:46 »

While you can find different definitions, and you could use google for that question, here is my version:

Basically there is no relevant difference. But I once heard the definition that a function returns something and a method does not. The method just does something while a function produces a result.

After all, it doesnt matter. Usually, no one makes a difference there, so you can use either word or both.

-JAW
Offline fletchergames

Senior Member





« Reply #4 - Posted 2007-09-14 20:02:08 »

"Function" is a math term that pretty much got hijacked by computer scientists (who were mathematicians).  A function takes a value from a set as an argument and produces a value from another set as a return value (with some restrictions that I can't remember as well as I should).

In computer science, function and method are used almost interchangeably, like the others said.  In either case, it's an algorithm that is performed and may optionally return a value.  It's not really the same as a math function because computer science functions/methods can do other things besides return a value (e.g. they can draw something on the screen).

So functions and methods the same, but you should call them methods to avoid confusion with people you probably won't talk to anyways.  Or, at least, that's my understanding of why Java has "methods" instead of "functions".
Offline rdcarvallo

Senior Member


Projects: 5
Exp: 15 years


2D Java games forever!


« Reply #5 - Posted 2007-09-25 22:12:19 »

I remember my first programming language, Turing.

There was procedures and functions, the diference was that procedures didn't return a value, and functions did.

That was easily translated in my mind to any function v/s void functions in my C days.

Now in Java my experience says that all are methods, bound to objects and classes (statics).

Offline Galgalid

Senior Newbie




L33T


« Reply #6 - Posted 2007-09-25 22:42:39 »

Methods is antoher word for functions Tongue Let's leave it to that shall we? Wink

I've never before built a program this stable, this secure, this L33T....

I want to be a member of the Sega Black Ops Team!
Offline keldon85

Senior Member


Medals: 1



« Reply #7 - Posted 2007-09-26 00:33:59 »

Methods is antoher word for functions Tongue Let's leave it to that shall we? Wink
Well the difference is good to know, some methods are functions, while some are procedures. Think that you could create a function that takes (say) a map and two points and returns a list of paths between the two points of minimal lengths. On the other hand you can have a procedure that performs operations on the map to highlight the shortest paths between the two points.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (24 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (50 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (55 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!