Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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