Roy G. Biv…

  • 3
  • Locked
In all ages, the rainbow has inspired artists and poets and served as a good omen for ordinary people. Programmers are also people capable of admiring the beauty of nature. Since we're talking about the aesthetics of the rainbow, let's create 7 objects. Each of them will display the name of one of the colors of the rainbow.
You can't complete this task, because you're not signed in.
Comments (24)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Kalyan Kumar Paramanandam
Level 4 , Richardson, United States
18 October 2020, 01:22
The order in which the objects are created must correspond to the order of the colors in the rainbow. even though the output is Red Orange Yellow Green Blue Indigo Violet
12 August 2020, 19:31
I am ok with it, that i have to create the objects. What i dont get here is the fact, that i do not have to call the mehtods inside the different colour classes ... why is this so? :)
Level 9 , Vienna, Austria
28 April 2020, 17:57
/* Comment has been deleted */
Level 41
29 April 2020, 07:27
Posting the solution in the comments is prohibited.
Sweetyyy Angel
Level 3 , Erode , India
3 April 2020, 06:23
i just created an object.Then,how it displays the color ????
Gellert Varga
Level 23 , Szekesfehervar, Hungary
5 April 2020, 23:38
It is need to know the constructor is just a method. When it's called, it will execute every commands in it. Even this included System.out.print command, too! Which one has nothing to do with constructing the object. You can put also any other commands into the constructor method. But it's not the best to do this.
Nickolas Johnson
Level 8 , St. Louis, United States of America
17 February 2020, 19:09
I guess I should have realized class constructors always run when the object is created
Michael T Schaefer
Level 15 , Columbia, United States
11 January 2020, 23:01
On my first try, I did... It didn't compile and gave me this output: "Error in com/codegym/task/task03/task0315/ on line 11 cannot find symbol symbol: method Red() location: class com.codegym.task.task03.task0315.Solution" What confuses me is that it seemed that what we were asked to do was the same as in the Level 2, Lesson 3 task ("One cat isn't enough). Clearly it's not though. It obviously has something to do with that "public Red... System.out.print..." code. Can anyone explain why?
Level 41
13 January 2020, 14:49
Please refer to Help section at our course.
Level 5 , Vijayawada, India
28 November 2019, 12:25
Please clarifz the code , I did this way but still facing Issues on the same
Muhammad Vahhaaj
Level 19 , Rawalpindi, Pakistan
4 June 2019, 19:21
Just: new Red(); new Orange(); creates new objects and if you are guessing the automatic output it's because of default constructors(println in constructors)
Level 4 , Nagpur, India
30 May 2019, 05:49
public class Solution { public static void main(String[] args) { //write your code here Red red = new Red(); } public static class Red { public Red() { System.out.println("Red"); } } } output of these program is red i want ask you that how object call the method.
Level 31 , Kosice, Slovakia
6 May 2019, 09:10
maybe it help for someone: // I have found it useful