Exercise 3-11: (1) Turn the AllTheColorsOfTheRainbow example into a program that compiles and runs.
public class AllTheColorsOfTheRainbow
{
int anIntegerRepresentingColors;
void changeTheHueOfTheColor(int newHue)
{
anIntegerRepresentingColors = newHue;
}
public static void main(String[] args)
{
AllTheColorsOfTheRainbow all = new AllTheColorsOfTheRainbow();
System.out.println(all.anIntegerRepresentingColors);
all.changeTheHueOfTheColor(1);
System.out.println(all.anIntegerRepresentingColors);
}
}
/*
javac AllTheColorsOfTheRainbow.java
java AllTheColorsOfTheRainbow
0
1
*/