Results 1 to 6 of 6
  1. #1
    lobodelbosque is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default Doubt with Objects

    hi;


    I dont understand what a statement like this mean;

    Light time1;

    Light is nonprimitive type and the statement is defining a variable that can hold a object reference or something like that.

    anyone can explain?
    thx

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    It defines the variable time1 as the type Light.
    My Hobby Project: LegacyClone

  3. #3
    lobodelbosque is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

    Default

    yes, but what does it mean "type light". I understand that , for example, the type int defines an integer, or a range of integers, but what define a custom made type? a range of numbers too?

  4. #4
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    right now it's just null. It would only get defined something concrete if you called it's constructor.
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  5. #5
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    Default

    So to answer your question more specifically yes it could be a range of numbers if that's what the Light class is set up with.

    Light type1;
    Light type2 = new Light();
    Light type3 = new Light(1,5);
    Light type4 = new Light("hello");

    type1 is set to null since nothing is constructed;
    type2 is set to whatever your default constructor would be;
    type3 is set to a range of values 1-5 assuming your constructor sets that up
    type4 is set to a new string

    All this means that your custom objects can be whatever you want them to be. Hell Light could even have multiple parts to it(range of values, colors from the spectrum, brightness etc). Everything depends on your constructors though.
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  6. #6
    lobodelbosque is offline Member
    Join Date
    Nov 2009
    Posts
    12
    Rep Power
    0

Similar Threads

  1. Doubt
    By karthikeyan_raju in forum Advanced Java
    Replies: 11
    Last Post: 11-05-2009, 04:48 PM
  2. doubt
    By Chris555 in forum Networking
    Replies: 0
    Last Post: 08-05-2009, 02:58 PM
  3. Replies: 1
    Last Post: 01-22-2009, 04:25 PM
  4. Doubt
    By winkodes in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 12-20-2008, 08:34 PM
  5. doubt
    By shaju_inspira in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-18-2008, 08:38 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
  •