Using Comparable interface to sort JAVA -


hi example have :

string1[0] ="banana"; string1[1] ="apple"; string1[2] ="pineapple"; string1[3] ="mandarin"; 

i want sort alphabetically using comparable , compareto() method. result be:

string1[0]="apple"; string1[1]="banana"; string1[2]="mandarin"; string1[3]="pineapple"; 

could show me skeleton of code plz ?

and there better way sort ?

just use arrays.sort():

arrays.sort(string1); 

this reorder strings lexicographically.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -