• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Becase Color.red return a Color object.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!I got it.
 
reply
    Bookmark Topic Watch Topic
  • New Topic