Practical Name: write a java program to accept employee name for user sort them in ascending order and display them (use array & object and static keyword
___________________________________________________________________________
public
class SortStrings {
static int n = 4;
static
String names[]= { "sakshi", "ruchita",
"muskan", "sanjiwani" };
static{
String temp;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++)
{
if (names[i].compareTo(names[j])
> 0) {
temp = names[i];
names[i] = names[j];
names[j] = temp;
}
}
}
}
void dispay(){
System.out.println("The names in
alphabetical order are: ");
for (int i = 0; i < n; i++) {
System.out.println(names[i]);
}
}
public static void main(String[] args) {
SortStrings o=new SortStrings();
o.dispay();
}
}
