我嘗試驗證數字並進行此功能。 public int digitCheck(String string)
{
int flag=0;
for(int i=0;i<string.length();i++)
{
if(!Character.isDigit(string.charAt(i)))
flag++;
}
我正在製作一個用戶擲骰子的遊戲,這個工作正常,然後我計算每個數字在我的countVals函數中滾動了多少次,但是它計數不正確,它計數1位數關閉。 如果擲骰 5,1,3,1,5 計數 預期的結果將是 2,0,1,0,2,因爲它計算了多少次,每次手指已經發生 實際結果是目前 0,2,0,1,0,2 代碼如下 for x in range (6):
#counter = dice.count(
我想製作一個程序,告訴我天氣我放入參數中的字符是大寫或小寫或從0到9的數字或其他!我在我的代碼中的錯誤: public class CharsTester {
public static void main(String[] args) {
char input;
if (input.matches("^[a-zA-Z]+$"))
{