Results 1 to 11 of 11
  1. #1
    hno2005 is offline Member
    Join Date
    Feb 2009
    Posts
    6
    Rep Power
    0

    Default What should I use class

    HI
    I’m learning java . I have a problem with using classes . Why should I use classes ? I saw very examples but I didn’t understand why should I use them ?
    Tnx

  2. #2
    wolfcro is offline Member
    Join Date
    Feb 2009
    Location
    Italy
    Posts
    51
    Rep Power
    0

    Default

    i think you have to read about object-oriented languages like Java.
    here are a few references:

    java.sun.com/docs/books/tutorial/java/concepts/
    sitepoint.com/article/oriented-concepts-java-1/

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    9

    Default

    I suggest following Wolfcro's advice. The class concept is *fundamental* to Java.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    10

    Default Closer to the real world...

    Yes... the links that wolfcro supplied will help you understand better the OOP concepts. A very simple way to explain OOP is a way to help to program to the real world (classes, objects, etc) that surrounds us (at least that's how I see it).

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    Actually, I think it is very simple if you are just beginning.

    There are 2 types of classes, a class with constructors and methods and a testing class with a main.

    Here is how you write them

    public class Example{
    Constructors;
    Methods();
    {

    public class ExampleTester {
    public static void main(String[] args) {

    Here you test the methods from the other class. This is the main class...you always HAVE to have this in any program.
    }
    }

  6. #6
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    9

    Default

    simplest answer is that you have to use classes.

    and you can just as easily put a main method in the actual class without having to create one just for testing purposes. i don't know why it seems to be so popular to do this.

  7. #7
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    It's popular because if you have a BIG program with ALOT of methods, ect. it is much easier to refer back to that and much more organized to have 2 classes.

  8. #8
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    9

    Default

    how is it much easier? i don't get it

  9. #9
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    It not necessarly easier, it's just more organized.

    So you don't have to scroll all the way up your main class and you other classes to determine which methods/constructors you have.

    It is more organized to create a seperate class for those.

  10. #10
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    9

    Default

    seems like your opinion is based on your experience writing code and what editor you're using, which goes into a larger argument in the sticky. let's just agree to disagree =p

  11. #11
    chango77745 is offline Member
    Join Date
    Feb 2009
    Posts
    27
    Rep Power
    0

    Default

    haha I guess your right.

    BTW I use eclipse for all my coding and I just started so I don't have much experience. Just a guy who listens to what my teacher says

Similar Threads

  1. problem calling function from class to class
    By alin_ms in forum New To Java
    Replies: 3
    Last Post: 12-19-2008, 08:35 PM
  2. Calling a method on original class from created class
    By kpedersen in forum Advanced Java
    Replies: 4
    Last Post: 08-20-2008, 12:25 AM
  3. Replies: 0
    Last Post: 05-13-2008, 06:16 AM
  4. Class Reflection: Finding super class names
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-23-2008, 08:12 PM
  5. Replies: 0
    Last Post: 04-02-2008, 07:04 AM

Posting Permissions

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