1. 程式人生 > >switch語句相關

switch語句相關

logs pre 允許 perm ase div span 枚舉 val

Cannot switch on a value of type long. Only convertible int values, strings or enum variables are permitted

switch無法作用於long類型的值。 只允許可轉換的int值,字符串或枚舉變量

String i = "2";
switch (i){
   case "1":
       System.out.println(1);
   case "2":
       System.out.println(2);
}    

switch語句相關