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
Printable View
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
It defines the variable time1 as the type Light.
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?
right now it's just null. It would only get defined something concrete if you called it's constructor.
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.
thx for your help.