it should be noted that you do not have to define a constructor for your class as G said..Java will handle it for you. However if you define even one constructor, Java will no longer automatically create that default constructor for you....you are now in charge or handling all of them
so if you want a constructor to define the color of an Apple object, then you MUST write a default constructor as well, even if there is no body to it.
So
so now in main if you create an apple say
it will call the default constructor, which will in turn call the other constructor with the parameters of red and 5.
if you write
it will call the constructor with the proper parameters, in the case, the other constructor and set the color to green, and number of apples to 3.
here is a quick read on
constructors [ August 21, 2004: Message edited by: jim gotti ]