switch語句的陷阱

下面的代碼是編譯不過去的。java

import java.io.*
public calss test{//條件表達式最終的數據類型應該和常量表達式一致
 public static void main(String args[])throw Exception
  String str;
     int a;
  BufferedReader buf;
  InputStreamReader isr = new InputStreamReader(System.in);
  buf = new BufferedReader(isr);
  str = buf.readLine();
  a = Integer.parseInt(str);
  switch(a)
 {
   case a<=100&&a>=90:
    System.out.println("優");break;
   default:System.out.println("dd");break;
 }it

}io

相關文章
相關標籤/搜索