• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

method and function

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the difference between method and function, why don't we call function in java instead of method whereas in c or c++ called function, is there any difference between function and method.
------------------
Harjeet Singh Dadwal
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, there is no difference. It's just that in java, they are called methods.

Bosun
 
Harjeet Dadwal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But I read in a book that there is a difference in that but no difference was described there.
* here we define function called method in a class itself that is why it is called method,
I think I read like this but I'm not able to remind which book I read in.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Java support methods , classes , interface.
methods must be declared in a class. if you want to access the method directly without accessing it through an instance of a class you delcare the method static.
Java supports of course constructors. No struct , no function because methods and function are the same in java. a method can be declared. final , static , private , protected , public abtract , default( no access specifier ) , native. ( Hope I didn't leave anything out. ). You can only have at most one access modifier, that is: public , protected , private.
There is no destructors in java. You can override finialize() and call super.
// Mathias
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


But I read in a book that there is a difference in that but no difference was described there. * here we define function called method in a class itself that is why it is called method, I think I read like this but I'm not able to remind which book I read in.


So there was a book you were reading that said Methods and Functions were not the same, but the book didn't explain the difference and you can't remember which book actually said this. Is that correct?
If so don't spend lots of time looking for the book and just take our word for it - they are the same thing.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
there is no difference b/w functions,methods and procedures in jave these all things are point out to the smae thing .. dont be confused about access modifiers.. ...
Umair Uddin Qa dd'rouy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic