assign a unique color to a array number in java -
hi guys im new programming code
for (int = 0; < v; i++) system.out.print(value[i] +" "); system.out.println();
value of "i" numbers , instead of printing value of "i" want print unique color each value example if value: "1 2 1 1 3" want print: "red blue red red green" how can this?
you can use switch
choose color
private string getcolor(int num) { switch (num) { case 1: return "red"; case 2: return "blue"; case 3: return "green"; default: return ""; } } (int = 0 ; < v ; ++i) { system.out.print(getcolor(value[i]) +" "); } system.out.println();
Comments
Post a Comment