Click to See Complete Forum and Search --> : 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?
poochi
May 7th, 2000, 02:21 PM
Post your code...
You can not call this method without creating instance of the class...
rahul_mkar
May 8th, 2000, 05:11 AM
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(){
}
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.