• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt regarding Interface methods

 
santanu biswal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

WHY INTERFACE METHODS ARE NOT STATIC??

I COULD NOT UNDERSTAND IT..

HELP ME..
 
Ulrika Tingle
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santanu biswal wrote:
WHY INTERFACE METHODS ARE NOT STATIC??

I COULD NOT UNDERSTAND IT.


What makes you think they should be static?
 
Muhammad Khojaye
Ranch Hand
Posts: 449
IntelliJ IDE Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see here. Hope it helps.
 
Rob Spoor
Sheriff
Pie
Posts: 20671
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santanu, please keep it down.
 
Ulrika Tingle
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
santanu biswal wrote:
WHY INTERFACE METHODS ARE NOT STATIC??

I COULD NOT UNDERSTAND IT..


Interface methods are implicitly abstract and abstract methods cannot be static. This is because static methods always must be given a body in the class where they're defined. And this is because they belong to the class where they're defined. They cannot be given a body in some other class the way abstract non-static methods can.

So interface methods are not static because that would go against the very nature of static methods. If interface methods could be static than they would be the same as non-static methods and it would be meaningless to maintain the difference. So if interface methods could be static then static methods would cease to exist.
 
santanu biswal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Ulrika Tingle ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic