public class Classifier{
public static void main(String[] args){
System.out.println(classify('n') + classify('+') + classify('2'));
}
static String classify(char ch){
if("0123456789".indexOf(ch) >= 0)
return "NUMERAL";
if("abcdefghijklmnopqrstuvwxyz".indexOf(ch) >= 0)
return "LETTER";
/*(Operators not supported yet)
if("+-*/&|!=".indexOf(ch) >= 0)
return "OPERATOR";
*/
return "UNKNOW";
}
}
Solution:
显示:不能通过编译。
if("+-*/&|!=".indexOf(ch) >= 0)语句里有*/注释符。注释符不可以这样嵌套/* xxx /* xxxx */ xxxx */
TID:
string literals are not treated specially within comments.
The best way to comment out a section of code is to use a sequence of single -line comments.