public class ConverTo { public static void main(String [] args)
{ String numberIn =args[0];
convertNum(numberIn);
}
static void convertNum(String num)
{
long showNumber;
String temp;
switch(num)
{ case "one":
temp = "1";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "two":
temp = "2";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "three":
temp ="3";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "four":
temp = "4";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "five":
temp = "5";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "six":
temp = "6";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "seven":
temp = "7";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "eight":
temp = "8";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "nine":
temp = "9";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break;
case "ten":
temp = "10";
showNumber = Long.parseLong(temp);
System.out.println(num+"convert to"+showNumber);
break; } } }
Long.parseLong(String s) 其中s必须是数字形式的字符串,才能运用该函数转化为长整型。