Results 1 to 6 of 6

Thread: main function, static>non-static?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181

    main function, static>non-static?

    i have some code here..

    Code:
    public void main(String args[]) {
    
         ......"some code here"
    		
    }
    
    public void readTiles() {
    
         ......"some code here"
    
    }
    but i get the error

    ** FileClassTester.java:4: non-static method read() cannot be referenced from a static context **

    why? what? i'm just accessing another function from the main function? i've done that a 100 times before? even if there's no code in readTiles() it give me an error.

    --770

  2. #2
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159
    Try that

    public void main(String[] argv) {

  3. #3
    Hyperactive Member bsw2112's Avatar
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    292
    public static void main(String args[])

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2001
    Location
    Ottawa, Canada
    Posts
    181
    i've tried that with staitc or without..

    if it's without, it says that i need a main function, if it's with, i can't call the other function?? ***??

    --770

  5. #5
    Hyperactive Member bsw2112's Avatar
    Join Date
    Nov 2001
    Location
    ottawa, canada
    Posts
    292
    can you post your entire code?

  6. #6
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    That is the nature of the language. Static members can only access other static members.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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