我有一個字符串數組,我試圖找出每個字符串中的字數。我明白如何找到單詞的總數,但它也包含了我不想要的數字。我試過s [i] .matches(「。\ d +。」),但只檢查字符串中是否至少有一個數字。我試圖找到總數(不是數字)。例如,一個字符串是「1776年7月4日舉行的國會大會」。即使只有3個字,我的代碼也會返回5個字,因爲它包含2個數字。
當我嘗試在單獨的類中打印myWords時,我得到一個空白語句。我很確定代碼是正確的,但我無法打印出我想要的單詞。請幫忙! public String[] multiLetter (int n, char included)
//public String[] multiLetter(int n, char included)
//returns an array of words with a
在以下兩個字符串中,在「兔子」和「樹」是匹配的: str1 = ('rabbit is eating grass near a tree');
str2 = ('rabbit is sleeping under tree');
假設cmp是宣告比較這兩個變量。我想要的結果如下: cmp = 2
或者表明兩個單詞匹配的東西。我該怎麼做呢?