switch case with data type byte

Switch statement work with byte,short,int,long, enum types, String and some wrapper type like Byte, Short, Int, and Long. the switch statement tests the equality of a variable against multiple values. Duplicate case values are not allowed. The value for a case must be of the same data type as the variable in the switch. The value for a case must be a constant or a literal. Variables are not allowed.


class Main {


    public static void main(String args[]) {


        byte by=10;


        switch((byte)(by+118)) {


            default:System.out.println("Sunday");


            case (byte)0:System.out.println("Monday");


            case (byte)128:System.out.println("Thank u");


        }

    }

}

Komentar

Postingan populer dari blog ini

100 alamat perusahaan Oil & Gas di Indonesia lengkap dengan no telpon

Seleksi Freshgraduate PT Pertamina 2017

Microgrid dan distributed generation akan mengubah energi masa depan kita