Results 1 to 2 of 2
  1. #1
    rahuld.exe is offline Member
    Join Date
    Apr 2012
    Posts
    1
    Rep Power
    0

    Default how can main call other methods?

    We declare main as static. But static functions can call only other STATIC functions. But main does call other functions (probably by using objects but still, the functions arent static). Please explain this to me.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,420
    Rep Power
    25

    Default Re: how can main call other methods?

    main does call other functions ... by using objects
    That is how a static method would call a non static method in a class. Get an object reference to the class:
    anObjRef.theMethodToCall(...);
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Java Noob, trying to call methods from another methods
    By gabrielpr12 in forum New To Java
    Replies: 8
    Last Post: 11-17-2011, 09:07 PM
  2. Call object methods from another class
    By africanhacker in forum New To Java
    Replies: 16
    Last Post: 03-22-2011, 01:10 AM
  3. Call Static Methods Outside Classes
    By Insomniac Riot in forum New To Java
    Replies: 4
    Last Post: 05-11-2010, 10:03 PM
  4. Rewrite as a function so it can call from main.
    By thangli in forum New To Java
    Replies: 2
    Last Post: 11-30-2008, 06:26 AM
  5. How to call methods of different classes
    By adeeb in forum New To Java
    Replies: 2
    Last Post: 06-06-2008, 06:08 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
  •