我從數據庫中得到的數據是1,2,3這樣的格式,我想在標簽中顯示為one,two這樣,應該怎麼實現?
謝謝
換一下就行,
public static void main(String[] args)
{
//這裡有定義成一個數組...這樣才方便
String x[]={"zero","one","two", "three","four", "five","six","seven","eight","nine",
"ten","eleven","twelve","thirteen","fourteen","fifteen", "sixteen","seventeen","eighteen","nineteen",
"twenty","thirty","fourty","fifty", "sixty","seventy", "eighty","ninety"
} ;
Scanner in = new Scanner(System.in);
String s;
s = in.next();//這裡用 next()方法
int j=0;
for(int i=0 ; i<x.length; i++ )
{
if(s==x[0])
{
//這裡判斷 如果輸入的字符串有和你數組裡定義的字符串有相同的 就跳出
//需要注意的是數組的索引是從0開始的所以對應的數組要+1
j=i+1;
}
}
System.out.println("你輸入的數字是"+j);
}