java - Unable to sort array in alphabetical order -
i trying sort array alphabetically having troubles step 3. here current code :
import java.util.arrays; import hsa.console; public class howtosortanarray { static console c; public static void main(string[] args) { c = new console (); string[] mystrarray = new string[500]; for(int i=0;i<5;i++) { c.print("input word: "); mystrarray[i]=c.readline(); } arrays.sort(mystrarray, string.case_insensitive_order); (int = 0; < mystrarray.length; a++) { c.println(mystrarray[a]); } } }
can explain me why code isn't working 1 is:
string[] words = new string[] {"b", "b", "a", "d"}; arrays.sort(words, string.case_insensitive_order); (int = 0; < words.length; a++) { c.println(words[a]); }
does have declaring array values? pretty lost.
you need change line to:
for(int i=0;i<mystrarray.length;i++); import java.io.console; import java.util.arrays; public class howtosortanarray { static console c; public static void main(string[] args) { string[] mystrarray = new string[5]; for(int i=0;i<mystrarray.length;i++) { system.out.println("input word: "); mystrarray[i]= "abdfg"; } arrays.sort(mystrarray, string.case_insensitive_order); (int = 0; < mystrarray.length; a++) { system.out.println(mystrarray[a]); } }
}
Comments
Post a Comment