Results 1 to 3 of 3
  1. #1
    sreeram is offline Member
    Join Date
    Dec 2012
    Rep Power

    Default Execute main class constructor

    Java Code:
    interface as 
        void d();
    /*class qwe implements as
    	public void d()
    		System.out.println("Hello World");	
    public class Interfaces implements as{
    	static int i=2,j;
    	public  void d()
    		System.out.println("Hello world");
       System.out.println(" the what ..?");
    public static void main(String args[])
      d();  //Cannot make a static reference to the non-static method d() from the type Interfaces...
      // qwe q=new qwe();
      // q.d();
    how to make a static reference???

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: Execute main class constructor

    You don't in fact want to make a static reference. The best course of action is to create an Interfaces object, and then call the d() method on that instance.

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Execute main class constructor

    The method 'd' can only be executed in assocation with an object.
    You need to create an Interfaces object (new Interfaces()).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Execute main args.length number of times
    By cherrychives in forum New To Java
    Replies: 3
    Last Post: 10-05-2012, 06:03 AM
  2. Replies: 4
    Last Post: 07-10-2012, 05:47 PM
  3. Running main method class from another main class
    By tlrocketman in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 09:30 AM
  4. Replies: 0
    Last Post: 12-19-2007, 10:10 AM
  5. Replies: 0
    Last Post: 12-19-2007, 10:01 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts