0 srinidhi kowshik · February 19, 2015
difference between function and method in java 

Post a Reply


Oldest  Newest  Rating
0 Branislav Lazic · February 19, 2015
There are no functions in Java. And generally methods are similar to functions.

Major difference is that methods are defined in classes and they do not require specific keyword for their definition. 
Such as: def, fun, df, function etc.

Concrete methods in Java require bodies, while in some programming languages function body is not required (i.e. Scala).

Methods in Java cannot have anonymous functions as parameters.

Methods in Java must have defined return type. In languages like Scala, return type is often optional.

Example of differencies: 


public int getValue() {
    return 0;

Equivalent in Scala for example:

// Requires keyword to be defined
def getValue(): Int = 0
0 Abdullah Nauman · February 19, 2015
Yes, its the mostly the same thing. Just a different word.
0 rubambura erck · February 19, 2015
hello friends, am new to this forum. well i need ur help to instal java jdk, to make make it internal. am tried to follow every step but when i type javac in cmd, its not working, it doesnt requognize java as an internal or external. i need ur help. using windows 8.1. thank u
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator