Learn how to use Java Short Hand Else...If (Ternary Operator)
This below code shows how you can use Java Short Hand else If\nshort-hand else if, which is also known as the ternary operator because it consists of three oper
# This below code shows how you can use Java Short Hand else If\nshort-hand else if, which is also known as the ternary operator because it consists of three operands.\n\n# 3 Operands\n1. condition followed by a question mark (?)\n2. then an expression to execute if the condition is true followed by a colon (:)\n3. and finally the expression to execute if the condition is false. \n\n\n# Code\n```\nclass Solution {\n    public List<String> fizzBuzz(int n) {\n        List<String> answer = new ArrayList<>();\n        for (int i= 1; i <= n; i++) {\n            answer.add(\n                i % 15 == 0 ? "FizzBuzz" : \n                i % 3 == 0 ? "Fizz" : \n                i % 5 == 0 ? "Buzz" : String.valueOf(i));\n        } \n        return answer;\n    }\n}\n```\n# Please upvote if it is useful\n![please-upvote-and.jpeg](https://assets.leetcode.com/users/images/26559736-d25f-4ecd-9a0f-822411c62d16_1680776289.3866694.jpeg)\n\n
['Java']