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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -