Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

interface behaviour  RSS feed

 
rahul mehra
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
interface isStack{
int b=0;
void push();
void pop();
static int a=0;
}
in the above interface if i declare a variable then is necessary to initialize the value explicitly.... cause if i'm not doing it i get a complie time error...that '=expected'

can anybody explain this behaviour......
 
Quang Pham
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
The int variable in your isStack interface class is final by default. Therefore it must have a value.
Quang
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!