Postingan

Menampilkan postingan dari Maret, 2023

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");         }     } }