単語のスタックがあり、「w」文字を含む最も長い単語を取得する必要があります。私はこうしてきました
public static boolean longestWWord(String s)
{
boolean hasw=false;
for(int i = 0; i < s.length(); i++)
{
if(s.charAt(i)=='w')
{
hasw = true;
}
}
return hasw;
}
System.out.println("Word with maximum 'w' chareckters : ");
int counter =0;
String word="";
for ( String ss : arr) {
if(longestWWord(ss)){
if(ss.length()>counter)
{
counter = ss.length();
word = ss;
}
}
}
System.out.println(word);
しかし今、単語に「w」が含まれているかどうか、および正規表現を使用してその単語の長さを見つけるタスクがあります。私を助けてください