aspose file tools
The moose likes Beginning Java and the fly likes this(Color.Red) ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "this(Color.Red) ? " Watch "this(Color.Red) ? " New topic
Author

this(Color.Red) ?

K Srinivasan
Ranch Hand

Joined: Mar 08, 2010
Posts: 34
Hi,
Can someone explain me this code from HFJ , chapter on constructors.



what does 'this (Color. Red) ;' do ?
specifically what is Color.Red ??

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19214

Color.red and Color.RED are static final fields of class java.awt.Color. Apparently this Color.Red is something similar.

As for "this(...)", it calls another constructor.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
eric totte
Greenhorn

Joined: Aug 13, 2010
Posts: 10
By default, the car is red. The default constructor calls the overloaded constructor.
K Srinivasan
Ranch Hand

Joined: Mar 08, 2010
Posts: 34
thanks :)
is


calling
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19214

It is indeed.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: this(Color.Red) ?
 
Similar Threads
New user: Enum with switch case
enums
Invoking one overloaded constructor from another with this()
Enum member variable access
Color??