Really noob question about classes

confused about classes and main

Page 1 of 1

4 Replies - 685 Views - Last Post: 01 February 2009 - 05:16 AM Rate Topic: -----

#1 clickfanatic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 11-January 09

Really noob question about classes

Post icon  Posted 26 January 2009 - 03:10 AM

Hi, Im still a noob at Java and Im quite confused some things:

1. What do i have to put in the main method?
2. How about in the main class?
3. Which class should I put my objects?
4. What materials would you recommend to help me learn the Program Logic Formulation

Sorry for the very noob question, Im just really confused...

Thank you for your time and hope you can help me clear things up.
Is This A Good Question/Topic? 0
  • +

Replies To: Really noob question about classes

#2 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: Really noob question about classes

Posted 26 January 2009 - 03:18 AM

1. Depends on your program
2. Depends on your program
3. Depends on your program
4. Can you define Program Logic Formulation?
Was This Post Helpful? 0
  • +
  • -

#3 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Really noob question about classes

Posted 26 January 2009 - 03:18 AM

check out this book, java, how to program 6th edition and your previous questions will be answered
Was This Post Helpful? 1
  • +
  • -

#4 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10488
  • View blog
  • Posts: 38,868
  • Joined: 27-December 08

Re: Really noob question about classes

Posted 26 January 2009 - 05:55 PM

Let's start with main. The method public static void main(String[] args) says to the Java Runtime Environment (JRE), or the Java interpreter/compile, the program starts here. Any code that directly affects the program & the logic go here. The objects that directly interface with the user go here. Any objects that interface with other classes go in those classes. For example, if you have a non-main class that requires an ArrayList, you instantiate that object in the non-main class. You would then instantiate that object in main. Your main class is the class with the main method in it.

Think about it this way: Your main class is like a body, and your main method is like the brain. You may have other organs like the stomach or heart. In the heart is the blood and in the stomach is food. However, the heart & stomach are both in the body. The stomach & heart in this metaphor are like your supporting classes/objects & the blood is like the ArrayList example I used above.

If you want a book to help with learning Java, pick up the Java for Dummies book. That's what I used to teach myself Java, and it works...I promise. I can't help you with a programming logic book, though. You just have to get your feet wet and go from there.

Hope this helps, and good luck with Java!
Was This Post Helpful? 1
  • +
  • -

#5 clickfanatic  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 11-January 09

Re: Really noob question about classes

Posted 01 February 2009 - 05:16 AM

View Postmacosxnerd101, on 26 Jan, 2009 - 04:55 PM, said:

Let's start with main. The method public static void main(String[] args) says to the Java Runtime Environment (JRE), or the Java interpreter/compile, the program starts here. Any code that directly affects the program & the logic go here. The objects that directly interface with the user go here. Any objects that interface with other classes go in those classes. For example, if you have a non-main class that requires an ArrayList, you instantiate that object in the non-main class. You would then instantiate that object in main. Your main class is the class with the main method in it.

Think about it this way: Your main class is like a body, and your main method is like the brain. You may have other organs like the stomach or heart. In the heart is the blood and in the stomach is food. However, the heart & stomach are both in the body. The stomach & heart in this metaphor are like your supporting classes/objects & the blood is like the ArrayList example I used above.

If you want a book to help with learning Java, pick up the Java for Dummies book. That's what I used to teach myself Java, and it works...I promise. I can't help you with a programming logic book, though. You just have to get your feet wet and go from there.

Hope this helps, and good luck with Java!


That explains it very well. Thank you very much
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1