-
static method
I am trying to call a method. When I try to compile, it gives a 'can't make static reference to void seat(int) in class Prog719'
the call is seat(request);
the method is defined as
public void seat(int request)
can you give me some insight into what I'm doing wrong, either from the error message or the little code I've given?
-
Re: static method
Post your code...
You can not call this method without creating instance of the class...
-
Re: static method
Hi,
this is the basic problem faced my many beginners in java programming. the problem is due to u r calling of the method from main which is a static method and is defined as "public static void main(string args[])". note the word "static" in the definition of main. thus u cannot put any non static declarations of methods in main. if u want to do so create an object and then call the objects instance method for example
public class c{
public static void main(String args[]){
c xyz=new c();
c.a method();
//amethod(); this will not work
}
public void amethod(){
}
}