Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Interface

 
Sujittt Tripathyrr
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why the Interface canot be static like

public static void display();

Thanks
 
sumeet saini
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Methods inside interface can't static, because these methods are implicitly public and abstract. And, modifiers 'abstrac' and 'static' can never come together.
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Why the Interface canot be static like

public static void display();


I did not get your question.

If you are asking why method declared in interface can't be static?

Then simple answer is interface methods are implicitly abstract. With abstract you can't combine any other non-access modifiers like static, synchronized etc. So they can't be static.

Naseem
 
Sujittt Tripathyrr
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Naseem

I cleared my doubts
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic