wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt" Watch "doubt" New topic
Author

doubt

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
g.setColor(Color.red.yellow.green.red.cyan);//1
g.drawLine(0,0,100,100); where g-graphicscontext
o/p--line with cyan color.
Why doesnt it give error in the argument of setColor??
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Becase Color.red return a Color object.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Because the member variables yellow,black, red etc of class "Color" are themselves instances of class "Color"
The following code compiles and prints 10.
<CODE>
-------------------------------------------------
class Test1
{
public static final Test1 testIns1=new Test1();
public static final Test1 testIns2=new Test1();
public static final Test1 testIns3=new Test1();
int i=10;
}
public class Test {
public static void main(String[] args) {
Test1 t = new Test1();
System.out.println(t.testIns1.testIns2.testIns3.i);
}
}
-----------------------------------------------------
</CODE>
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Thanks!I got it.
 
wood burning stoves
 
subject: doubt