Javaで利用可能な最高の文字列値を取得したいのですが、どうすればこれを達成できますか。
例: こんにちはジェームズワンフロン
最高の文字列「jameswangfron」を取得したい
String Text = request.getParameter("hello jameswangfron");
コード例をください。
public class HelloWorld{
public static void main(String []args){
String text = "hello jameswangfron";
String[] textArray = text.split(" ");
String biggestString = "";
for(int i=0; i<textArray.length; i++){
if(i==0) {
textArray[i].length();
biggestString = textArray[i];
} else {
if(textArray[i].length()>textArray[i-1].length()){
biggestString = textArray[i];
}
}
}
System.out.println("Biggest String : "+biggestString);
}
}
そして、それは出力を次のように示します
Biggest String : jameswangfron