Results 1 to 15 of 15
Like Tree1Likes
  • 1 Post By jim829

Thread: main() class

  1. #1
    khangura is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Default main() class

    hi guys.........today i wrote my first java programme.......i built up two classes and third being the class containing the main() function..........i was wondering i had to create objects for the first two classes in the main() class but the class with main() works by itself.............how does it works??

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,602
    Rep Power
    5

    Default Re: main() class

    Main is the static entry point which is invoked by the JVM once the class is loaded. Here is the ref in the JLS (a good source of info on Java and its design).
    Chapter*12.*Execution

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: main() class

    Your text book explains it all, so there's no need to regurgutate it here again.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,602
    Rep Power
    5

    Default Re: main() class

    Lol. I had to laugh because I mentioned this to my son who is taking Java in high school. First they don't teach him the way I learned. They use Karel (which I find ridiculous). Second they don't have a text book. They just use handouts. And when textbooks are available for other subjects some of them are online and they are bad (can't print out pages to annotate, etc). I hope it's better where you live.

    Regards,
    Jim
    Last edited by jim829; 01-20-2014 at 06:11 PM.
    Naitwa likes this.
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: main() class

    Not really; book stores that had been doing well for more than a century are going broke now; people are dumping their private bullsh*t on 'teh internet' while complaining about their lack of privacy and they all want the latest free apps on their phones; the world is going berzerk and reading a book is not part of that world, but online course material should be at least as complete as the old book version, there's no excuse for that imo.

    kind regards,

    Jos (<-- almost extinct specimen of the 'reader')
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: main() class

    Well what I see is that people still read - just not paper books but rather (illegally downloaded) digital versions on their e-reader/smartphone. Which is fine with me, I'll stick to the paper variant for as long as I can though, I'll adapt in the very last moment like I usually do. I was doing some research if a smartphone is finally interesting and worth the price to me and nope, it still isn't. Another year living like a caveman with my old Nokia, my regular desktop computer and my paper books; I'm so happy with it all!

    But its still all collapsing around me since people that used to buy paper books WILL download the e-books for free because it is so easy to get (without exception so far) even when the E version is 5-10 euros/dollars cheaper than the paper version; how long is it going to take before authors give up spending a year+ writing something that people then won't even have the decency to pay for :/ I thank something or another that paper books are still more popular than digital variants, but that is going to rapidly shift this year or at most next year I'll bet.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Daryn is offline Senior Member
    Join Date
    Oct 2012
    Posts
    176
    Rep Power
    2

    Default Re: main() class

    How do you know he even has a text book or is in a class at all
    With the right know how, anything is possible

  8. #8
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: main() class

    Quote Originally Posted by Daryn View Post
    How do you know he even has a text book or is in a class at all
    I don't think its so much as knowing that he is, its more a matter of HOPING that he is.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: main() class

    Quote Originally Posted by gimbal2 View Post
    I don't think its so much as knowing that he is, its more a matter of HOPING that he is.
    And whether or not being in a class, learning Java without a text book (electronic or not) is just a silly exercise ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    khangura is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

    Default Re: main() class

    @jim thanks for the explanation........i will look into the resource too...!
    @josah i currently not having a book but i am deciding to get one......!
    i am in college guys but lerning java is not my subject i am just learning it for fun i love to program

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,602
    Rep Power
    5

    Default Re: main() class

    Perhaps you should take Java in college as an elective and get credit for it. I don't know what you're studying but I was a biology major. I took a course in Fortran and noticed that when I was working on my programs that hours would fly by in no time. So I figured, that's what I wanted to do so I switched majors.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  12. #12
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,520
    Blog Entries
    7
    Rep Power
    20

    Default Re: main() class

    Quote Originally Posted by jim829 View Post
    Perhaps you should take Java in college as an elective and get credit for it. I don't know what you're studying but I was a biology major. I took a course in Fortran and noticed that when I was working on my programs that hours would fly by in no time. So I figured, that's what I wanted to do so I switched majors.
    If you wanted something to do that makes time fly by, why didn't you become a mattress tester?

    kindest regards,

    Jos (<--- oooh! he said 'mattress'!)
    cenosillicaphobia: the fear for an empty beer glass

  13. #13
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,602
    Rep Power
    5

    Default Re: main() class

    Quote Originally Posted by JosAH View Post
    If you wanted something to do that makes time fly by, why didn't you become a mattress tester?
    LOL!! That is great! (I think I'll go take a nap now) :)

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  14. #14
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,004
    Rep Power
    6

    Default Re: main() class

    The joke I had in mind as a response to that was just too cruel, I couldn't do it. I respect my seniors.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  15. #15
    khangura is offline Member
    Join Date
    Jan 2014
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Replies: 16
    Last Post: 11-20-2013, 12:43 PM
  2. Error: Could not find or load main class Test.class
    By java_aim in forum New To Java
    Replies: 11
    Last Post: 08-13-2013, 05:05 PM
  3. Replies: 1
    Last Post: 11-29-2012, 09:46 AM
  4. Replies: 11
    Last Post: 10-30-2012, 09:28 AM
  5. Running main method class from another main class
    By tlrocketman in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 08:30 AM

Tags for this Thread

Posting Permissions

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