|
-
May 6th, 2000, 01:09 PM
#1
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?
-
May 7th, 2000, 02:21 PM
#2
Re: static method
Post your code...
You can not call this method without creating instance of the class...
-
May 8th, 2000, 05:11 AM
#3
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(){
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|