Create an Entity property to compareCharacter creation comparison
Public class zonecomparatorname implements comparator<zonedto> {
@Override
Public int Compare (Zonedto Z1, Zonedto Z2) {
String name1 = Z1.getname ();
String name2 = Z2.getname ();
if (Name1.compareto (name2) > 0)
{
return 0;
}
Else
{
return -1;
}
}
}
Plastic comparison
Public class zonecomparatorstreet implements comparator<zonedto> {
@Override
Public int Compare (Zonedto Z1, Zonedto Z2) {
int age1 = Integer. parseint (Z1.getstreet ());
int age2 = Integer. parseint (Z2.getstreet ());
if (Age1 > Age2)
{
return 0;
}
Else
{
return -1;
}
}
}
Create the entities you want to compare
public class Zonedto {
name
private String name;
Private String Street;
Public String GetName () {
return name;
}
public void SetName (String name) {
THIS.name = name;
}
Public String Getstreet () {
Return Street;
}
public void Setstreet (String street) {
This.street = Street;
}
}
Making attribute Comparisons
for LIST< &NBSP;ZONEDTO&NBSP; >
zonecomparator name pcomparatorstreet = new zonecomparator name ();
collections. Sort (result, pcomparatorstreet);
Ordering of object properties in ArrayList