0 =〉 no apples 1 =〉 an apple 2 =〉 apples 下面這個例子更復雜一些:
less than 0 =〉 freezing less than 10 =〉 chilly less than 30 =〉 nice greater than 30 =〉 too hot greater than 100 =〉 boiling 寫代碼時一種解決方案是使用“if…else”語句,還有一種解決方案是使用“switch-case”語句。但事實上還有一種最簡單的方法,盡管很少有人去用它,那就是使用java.text.ChoiceFormat類。