I would like to work with the item object but I need to pass values from my activity to the util one can you explain?
item[0] = new ColorClothes();
item[0].record = 0;
item[0].color = "blue";
item[0].clothes = "shoes";
For example where "blue" would like to receive a value from my activity how could it be?
import java.util.*;
public class ColorClothes
{
public int record;
public String color;
public String clothes;
public static void main(String[] args)
{
Initialize();
}
public static void Initialize()
{
ColorClothes item[] = new ColorClothes[4];
item[0] = new ColorClothes();
item[0].record = 0;
item[0].color = "blue";
item[0].clothes = "shoes";
item[1] = new ColorClothes();
item[1].record = 1;
item[1].color = "yellow";
item[1].clothes = "pants";
item[2] = new ColorClothes();
item[2].record = 2;
item[2].color = "red";
item[2].clothes = "boots";
item[3] = new ColorClothes();
item[3].record = 3;
item[3].color = "black";
item[3].clothes = "coat";
System.out.println("Unsorted");
for(int i = 0; i < item.length; i++)
{
System.out.println(item[i].record + " " + item[i].color + " " + item[i].clothes);
}
System.out.println("\nSorted By Color\n");
Arrays.sort(item, new ColorComparator());
for(int i = 0; i < item.length; i++)
{
System.out.println(item[i].record + " " + item[i].color + " " + item[i].clothes);
}
System.out.println("\nSorted By Clothes\n");
Arrays.sort(item, new ClothesComparator());
for(int i = 0; i < item.length; i++)
{
System.out.println(item[i].record + " " + item[i].color + " " + item[i].clothes);
}
}
}