提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用switch语句进行转换
public class Main { /*来自 N o w J a v a . c o m - 时 代 Java*/ public static void main(String[] arguments) { long num = 0; char firstChar = 'a'; char secondChar = 'i'; switch (firstChar) { case 'o': num = 1L; break; case 't': if (secondChar == 'w') num = 2L; if (secondChar == 'h') num = 3L; if (secondChar == 'e') num = 10L; break; case 'f':// from 时 代 J a v a 公 众 号 - N o w J a v a . c o m if (secondChar == 'o') num = 4L; if (secondChar == 'i') num = 5L; break; case 's': if (secondChar == 'i') num = 6L; if (secondChar == 'e') num = 7L; break; case 'e':