This discussion is archived
1 Reply Latest reply: Jan 9, 2013 9:52 PM by EJP RSS

Main method question in java, please help

983190 Newbie
Currently Being Moderated
Guys I have looked all over the internet, and cannot understand any of these questions: I would really appreciate any help on them. The first, and most important thing I would like to know is, what is static: what is a static int, or a static main method? Why is this necessary, and what does it do? Could you please provide an example? Also, why is String[] args necessary within the parameters of the main method? Is this so that it can execute it? Last thing is: objects. Where can I learn about them? I know they are made with the new operator, but don't understand their use? Could you explain why they are useful? Can you give them values? and how do they relate to the dot operator? After these are answered, I will be so happy because I will feel like I actually know a little bit. Right now, I'm just confused... Thank you so, so much in advance!
  • 1. Re: Main method question in java, please help
    EJP Guru
    Currently Being Moderated
    The first, and most important thing I would like to know is, what is static
    'static' means that the item concerned is associated with the class itself rather than an instance: so, it is accessible to all instances.
    Could you please provide an example?
    public static void main(String[] args)
    is an example, but you knew that. I don't really understand the question.
    Also, why is String[] args necessary within the parameters of the main method?
    'args' receives the arguments you type on the command line after the class name or jar name, depending on how you invoke the application.

    This is all covered in the documentation, which you should read before asking further questions.
    Last thing is: objects. Where can I learn about them?
    If you don't know about objects you're not going to learn about them by asking questions on a forum. It's far too large a topic. Get yourself a book.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points