The mathematicians that hang around this forum will probably tell you that a function is a method that returns exactly one value.
There are different notions about functions and methods: a method in Java can
do what it wants: bake a cake for you, print "foo" on every paper page in your
printer until the printer is out of paper, attempt to format your harddisks and a
lot more usefull things. A function in Java can do the same but it must return
a value of a certain type.
A lot more restrictive (but very useful) functions are the 'referential transparent'
functions: those functions don't have side effects (no cake, no out of paper and
no fresh hard disks) and every time you call them with the same parameter
values they return the same value again and again. According to this definition
e.g. the Random.nextint() method is not a function.
Of course mathematics nags a bit further about, e,g. continuous functions,
bijective, injective, surjective functions, (primitive) recursive functions, computable
functions and the list goes on and on. Those mathematicians are loonies, there's
no need to pay any attention to them when you deal with Java.
kind regards,
Jos