This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

method and function

 
Harjeet Dadwal
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • 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
 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • 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
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • 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.
 
Umair Uddin
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic