I have Kvote class like this:
public class Kvote {
private static int counter = 0;
private double[] vrednost = new double[3];
private int id;
public Kvote(double v1, double v2) {
super();
this.vrednost[1] = v1;
this.vrednost[2] = v2;
this.id = counter;
counter++;
}
public static int getCounter(){
return counter;
}
}
I have created several objects of that class in Main:
Kvote k1 = new Kvote(2, 4.25);
Kvote k2 = new Kvote(1.85, 5);
Kvote k3 = new Kvote(1.62, 6.5);
Kvote k4 = new Kvote(1.72, 6);
So, every instance of class Kvote has some id, it's 0 for k1, 1 for k2, 2 for k3... Is it possible to access objects by it's id var value. For example if I ask for object with Id=2, I get object k3...
It's hard for me to explain why I need this, but I do. Basically, my alghorytm needs to work with infinite number of objects of class Kvote: k1,k2,k3,k4,k5,k6,k7....