Results 1 to 3 of 3
  1. #1
    Zarquad is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default Concept of Objects

    I'm starting to get a bit confused. I know that a class is a collection of objects that have similar behaviour. That part that confuses me is that methods are used on objects, so does that mean that objects are simply variables?

  2. #2
    Zarquad is offline Member
    Join Date
    Jul 2013
    Posts
    14
    Rep Power
    0

    Default Re: Concept of Objects

    Okay, I think that I might have figured it out. Are objects estientially "variable types" such as String, int, etc, that you yourself or somebody else has created? They do not include primitive types such as int, String, float, and boolean, but do include things such as Rectangle and Point, along with any other types that you create yourself? Is that right?

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,038
    Rep Power
    10

    Default Re: Concept of Objects

    I just wrote a tutorial going through the basics, it might help you understand some of the concepts: Objects - Tutorials - Static Void Games

    But to sum it up briefly:

    Think of a primitive variable, like an int or a boolean. They are stateless, in that you can't have any extra information along with them. You can't have an int with an associated color, for example.

    Objects are values that have a state. You can think of this state as a collection of other values that describe that object. For example a person object might have a value for height, another for weight, another for name, etc.

    A class is a blueprint for creating an object. It's a way to create that group of values to establish what defines an object's state. A person class will simply list the variables that need to be defined in order to create a person from that blueprint.

    You use that class to create multiple copies of the object, each with their own state maintained by the values "inside" that object. Those copies are called instances.

    Objects also have their own methods and whatnot that change the state, but the gist is that an Object defines a certain state, and a class is used as a blueprint for creating different copies, or instances, of that object.

    I'm sure these definitions can be nitpicked apart, but that's the basic idea.

    String is an Object, since it has things like a length, the characters being held, etc.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Java concept help
    By DMarsh12 in forum New To Java
    Replies: 1
    Last Post: 02-15-2012, 08:06 PM
  2. Array Concept
    By sandeep43 in forum New To Java
    Replies: 11
    Last Post: 08-04-2011, 01:19 PM
  3. Map concept in JAVA
    By Mathan in forum New To Java
    Replies: 19
    Last Post: 06-27-2008, 07:02 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
  •