doubt in main()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ramya kandasamy
    New Member
    • Apr 2010
    • 9

    #1

    doubt in main()

    can we write main ( ) without static keyword.if yes tell me the way.Because i am getting run time exception.
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    You can, but then main will just be a member function and can't be used to enter the program.

    What is your runtime exception?

    Comment

    • jkmyoung
      Recognized Expert Top Contributor
      • Mar 2006
      • 2057

      #3
      "ramya kandasamy
      i am geetiing run time exception like below :

      exception in thread "main" java.lang.no such method error:main
      "
      Can we see your main method declaration? Is it public?

      Comment

      • Dheeraj Joshi
        Recognized Expert Top Contributor
        • Jul 2009
        • 1129

        #4
        You can write a main function without static, but in your class you must have a public static main class for entering into the program.

        For entering to a program you need a main, it must be public and static.

        Regards
        Dheeraj Joshi

        Comment

        Working...