Hi guys, I'm trying to sort a string array that has 100 words using the selection sort algorithm. Here's my code so far:
Is my code correct?import java.util.*; class arraysort{ public static void main(String args[]){ int index,number=0; Scanner input = new Scanner(new File("wordlist.txt")); String words[] = new String[100]; String max,k; for(int i=0;i<words.length;i++){ number = (int)(Math.random()*10); for (int j=0;j<number;j++){ words[j] = input.nextLine(); } for (int i=0;i<99;i++){ { max = a[i]; for (int j=i+1;j<100;j++) { if (a[j].compareTo(max)>0) { max = a[j]; index = j; } } k = a[i]; a[i] = a[index]; a[index] = k; } } } }