CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: static method

  1. #1
    Guest

    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?



  2. #2
    Join Date
    Sep 1999
    Location
    Madurai , TamilNadu , INDIA
    Posts
    1,024

    Re: static method


    Post your code...

    You can not call this method without creating instance of the class...


  3. #3
    Join Date
    May 2000
    Posts
    1

    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
  •  





Click Here to Expand Forum to Full Width

Featured