jeudi 29 octobre 2015

Java nested if to switch statement

I'm having trouble transforming the following nested if statement below, into an equivalent switch statement. If anyone can give me some advice, it would be appreciated.

if (num1 == 5)
    myChar = ‘A’;
else
if (num1 == 6 )
    myChar = ‘B’;
else
if (num1 = 7)
    myChar = ‘C’;
else
    myChar = ‘D’;

Aucun commentaire:

Enregistrer un commentaire