java - how to use non-static function inside of static function -


here class..

public class oop {     int count = 0;      public static void main(string args[])     {         this.count(15, 30);         system.out.print(this.count);     }      public void count(int start, int end)     {        for(;start<end; start++)        {            this.count = this.count + start;        }     } } 

i can't call count function inside of main function. reason static , non-static functions. i'm new java. how can use count inside of main? need learn?

you need instantiate oop , call method it, this:

oop oop = new oop(); oop.count(1,1);  

for further information check out: difference between static methods , instance methods


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -