Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Need some hints (two questions)

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Location
    Gjilan
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need some hints (two questions)

    Hello everybody. I am a beginner at Java programming and I am trying to learn things in deep details. I can see that this forum is very helpful. At first, I had some problems to post, but after I read some rules my mind changed and I didn't just post them, in fact I solved them by using the advises given in some of the articles. But I have two questions, that I can't really find its answers. (My teachers say that they will explain them in next semester. Frankly I don't know the reasons (perhaps they might think of us incapable of understanding everything at once)). I would be grateful if I could get some help with the following two questions:

    1. When we start a program, the "class is copied into primary storage and becomes an executing object". I don't find this quite understanding, in fact it's quite complex in my mind, so can anybody help me to find/understand the precise explanation?

    2. Is there a difference (perhaps in later use of the program) between writing this piece of code:

    GregorianCalendar c = new GregorianCalendar();
    System.out.println(c.getTime());


    and

    System.out.println(new GregorianCalendar().getTime());


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,400
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Need some hints (two questions)

    I'm not really sure what your first question is. Do you mean when you start the program, or when a class is loaded, or when it's instantiated? Those are some good google keywords for you.

    As for your second question, what happened when you tried? The only difference is that you're storing the Calendar in a variable, so you have access to it after you instantiate it.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Oct 2011
    Location
    Gjilan
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need some hints (two questions)

    Thank you for replying.
    Quote Originally Posted by obel1x View Post
    1. When we start a program, ...
    When we start the program, I said it at the very beginning of the question. Let me know if it's still not comprehensive enough. About the second one, I tried both but I didn't use any reference after so it worked fine. But now I understand. You're right, I got your point, thanks for the explanation.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,400
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Need some hints (two questions)

    Quote Originally Posted by obel1x View Post
    Thank you for replying.

    When we start the program, I said it at the very beginning of the question. Let me know if it's still not comprehensive enough. About the second one, I tried both but I didn't use any reference after so it worked fine. But now I understand. You're right, I got your point, thanks for the explanation.
    I read your question. My point was that your assumption didn't make a ton of sense to me. But really, why do you think you need to know this? It should have no impact on your programs whatsoever.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Oct 2011
    Location
    Gjilan
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need some hints (two questions)

    Which assumption? Well, as I said I am just curious how things work in details, something like what happens with cells, bits, classes, objects etc. I want to know every time I write some code, what is really happening in computer ..

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,624
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: Need some hints (two questions)

    I want to know every time I write some code, what is really happening in computer .
    To understand that you need to learn assembly language, learn how the linker program works and how the loader works and how the OS gets involved when you start executing a program.
    None of which is really needed for java programming.

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,400
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Need some hints (two questions)

    Quote Originally Posted by obel1x View Post
    Which assumption? Well, as I said I am just curious how things work in details, something like what happens with cells, bits, classes, objects etc. I want to know every time I write some code, what is really happening in computer ..
    The assumption that when a program is started, the "class is copied into primary storage and becomes an executing object". Where are you getting that? What exactly is meant by "when a program is started"? There are multiple stages to program startup.

    But yeah, these kinds of implementation details usually do not matter- and in fact, different environments might do different things, so it's best not to worry too much about them.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Junior Member
    Join Date
    Oct 2011
    Location
    Gjilan
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need some hints (two questions)

    Quote Originally Posted by Norm View Post
    To understand that you need to learn assembly language, learn how the linker program works and how the loader works and how the OS gets involved when you start executing a program.
    None of which is really needed for java programming.
    Obviously what you're saying is true. Of course it's not needed, but I think it's good to know .. however it's just my curiosity that matters here

  9. #9
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,400
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Need some hints (two questions)

    Quote Originally Posted by obel1x View Post
    Obviously what you're saying is true. Of course it's not needed, but I think it's good to know .. however it's just my curiosity that matters here
    If you're really that curious, the JLS is your friend: Execution
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Few questions
    By CSUTD in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 11th, 2011, 09:23 PM
  2. JRE and JDK Questions
    By beer-in-box in forum Computer Support
    Replies: 11
    Last Post: September 16th, 2011, 05:37 PM
  3. Many questions
    By SharpT in forum What's Wrong With My Code?
    Replies: 11
    Last Post: January 18th, 2011, 08:56 PM
  4. A few questions
    By adenverd in forum Java Theory & Questions
    Replies: 3
    Last Post: May 26th, 2010, 03:34 AM
  5. [SOLVED] Some serious questions,
    By Time in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 17th, 2010, 02:52 AM