Color color; if(str.equals("red")) color=Color.red; else if(str.euqals("yellow")) color=Color.yellow; ... ...