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

Abstract classes and non-static variable this cannot be referenced from a static context  RSS feed

 
John Losty
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do I get a compile error in Netbeans when I type this code:



and this guy on the video doesn't have the error?

youtube: video
 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the {} carefully. I think your Test class is an inner class whereas it is supposed to be a top‑level class. An inner class is implicitly an instance member of its surrounding class. If you convert all your classes to top‑level classes, I think your problem will be solved. You only need to move one }
 
John Losty
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh I see, thanks
 
Campbell Ritchie
Marshal
Posts: 55681
162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!