✏️ Explanatory Question

Question:

Given the following code fragment:

if (a == 0) System.out.println("Zero");
if (a == 1) System.out.println("One");
if (a == 2) System.out.println("Two");
if (a == 3) System.out.println("Three");

Write an alternative code (using if) that saves on the number of comparisons.

👁 67 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

Answer not available right now.