java - how to use non-static function inside of static function -
this question has answer here:
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
Post a Comment