public static void main (String Args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter String");
String s = br.readLine();
s=s+" ";
s.toLowerCase();
String word="";
String max="";
int count=0;
for(int i=0; i<s.length();i++){
char ch = s.charAt(i);
while(ch!=' ')
word+=ch;
if(word.length()>max.length()){
max=word; count++;
}
else count++;
}System.out.println(max+" , "+count);
}
}
我想查找字符串中最大的單詞而不使用拆分或類似的東西,並且還要計算句子中有多少單詞。 當我輸入任何東西,然後按回車沒有任何反應。問題是什麼?BufferedReader即使按下輸入鍵後也沒有輸入
謝謝。這是一個蹩腳的錯誤。 – NobleSiks
歡迎您:)) –