Which way is efficient? Thank you all in advance. Have a nice day.
I have a simple class which will call a function from main() method. Since we cannot access non-static methods from static context: should I declare the called function as static or should I create an object of the class in which main() is declared.
Which way is efficient?
I can say.. static and non-static have different meaning. So first check the method which you want to call. If the method looks like same for all object of the class then its a static method. That means a method having static characteristic should be declared as static and not any/all method just for the ease of calling it.
I hope you get my idea.
In this example I created an object to the PrimeNumber class and accessed the valid(String) method. However I can access it by declaring it as static. In this particular case which way is efficient?
Thank you in advance.
Way to go :-)
Is it clear to you now..I hope so.
Anyway thanks for quick responses.
At the moment a is declared outside the valid method and isn't static so couldn't be used inside valid if you made that method static.
At least that's what I understand.
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
The WEB SERVICES and JAX-RS Coursehttps://coderanch.com/t/690789/WEB-SERVICES-JAX-RS