1 java sorting algorithm bubble-sort
我的任务是询问用户他想输入的字符串数量.然后我会提示他纠正弦乐.然后我应该按字母顺序打印蜇伤.我完成了大部分任务,只需要一个排序算法,如冒泡排序来完成它.这是我的代码.
import java.io.*;
public class sorting
{
private static BufferedReader stdin=new BufferedReader(new InputStreamReader( System.in));
public static void main(String[] arguments) throws IOException
{
System.out.println("How many strings would you like to enter?");
int stringCount = Integer.parseInt(stdin.readLine());
String[] stringInput = new String[stringCount];
for(int i = 0; i < stringCount; i++)
{
System.out.print("Could you enter the strings here: ");
stringInput[i] = stdin.readLine();
}
//Now how do i use a sorting algorithm?
}
}
Run Code Online (Sandbox Code Playgroud)