err msg - Cannot make a static reference to the non-static method Multiply123(int, in
When i run the below code -
public class Sample
public static void main(String args)
public int Multiply123(int x,int y)
getting the error message.
You shouldn't call non static method directly to static method..either u have to make it static or create object
To clarify on the above explaination.
Methods can be either "instance" (non-static), or "static" which means they do not reference any member variables. If a method is "static" than it cannot call any member variables, properties, or methods, only static ones.
In your case, you can simply add the keyword "static"
If the class requires a member property or method to be called, then you'll have to instantiate a new object of that class. (generally by using the 'new' keyword).
Read more about different types of scoping of methods,
What scenario you are trying with this. DO you really need static methos, or you work can be achieved by non-static method?
It is because - static prop and methods load into JVM when we run a prog but non-static will be loaded only upon the object instance hence if you try to access a static method into a non-static method without the use of object - it will throw reference error.