Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

non static referenced from a static context?  RSS feed

 
Brad Wong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing a program to calculate interest with a separate method for the calculation, but it won't compile...any help?

 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, please UseCodeTags.

No, first, welcome to JavaRanch!

Second, please UseCodeTags.

Now, you can't reference non-statics from statics. Either declare your method static, or create an instance of your class and use that to call the method.
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is not simple interest you are calculating, but compound interest. If you find the most dubious classification of methods known to modern science, that comes to be a 1368. You could therefore consider making it static.
Note you can’t override static methods, nor make interface methods static.
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey, I like that classification system! Sort of a Meyers-Briggs for methods.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!