package com company import java util Arrays public class Main public s

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package com.company;
import java . util . Arrays ;
public class Main {
public static class Lab implements Comparable<Lab>{
private String s ;
public Lab(String s) { this.s = s; }
public String toString () { return s ; }
public int compareTo( Lab obj ) {
return s.charAt(0) - obj.s.charAt(0); //code
}
}
public static void Lab(String[] args) {
Lab [] a = new Lab [] {
new Lab ("Mother"),
new Lab ("Father"),
new Lab ("Grandfather")
};
Arrays.sort(a);
for (Lab s : a) System.out.println(s);
}
}