1

Since I started to learn Java recently I would like to be clear on some terms. As I learn, subroutine can be called as a method ... Subroutine is an instruction that consists of the sequence of "statements" enclosed between braces... from my understanding main method public static void main (String[] args)

is subroutine am I right? Thanks in advance

  • Subroutine sounds like a very lowlevel view of things (i.e. any code you can jump to). Otherwise yes: http://stackoverflow.com/questions/155609/what-is-the-difference-between-a-method-and-a-function – zapl Feb 09 '14 at 23:45
  • helps to differ ...Thank you –  Feb 09 '14 at 23:49
  • http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html – JamesB Feb 09 '14 at 23:51
  • As you continue to explore Java you will find that there is an important reason "subroutines" are called methods. They always belong to an object. (There exists an object called 'this' which holds state and is implicitly called to scope every field/method [myMethod() becomes this.myMethod()] as a method is only callable on an instance in Java, unless it is static). This gives rise to polymorphism and a bunch of other clever things in Object Oriented Programming. – ebolyen Feb 09 '14 at 23:52
  • Thank you for expanding this topic it is interesting –  Feb 10 '14 at 00:02
  • regarding "static": http://programmers.stackexchange.com/questions/20536/static-methods-or-static-functions you could differentiate between true stateless functions (in the sense of a mathematical function) and methods of the class if you want to get philosophical - or simply call everything method – zapl Feb 10 '14 at 00:03
  • And note that this applies to all object-oriented languages. It isn't specific to Java and in fact it predates Java considerably. – user207421 Feb 10 '14 at 00:21
  • Thank you I will keep in mind –  Feb 10 '14 at 00:34

1 Answers1

0

Yes you are right. Method is an object oriented jargon for subroutine. A method is a subroutine or function that you can call on an object in an OO language.

Amal Murali
  • 75,622
  • 18
  • 128
  • 150
kiki
  • 81
  • 9