I'm working on a big project, but for this question I write a simple example of the problem. I have 2 classes.
public class Main
{
public static void main(String[] args)
{
CustomType[] customType = new CustomType[3];
for(int i = 0; i < 3; i++)
{
customType[i] = new CustomType(i);
}
for(int i = 0; i < 3; i++)
{
System.out.println("Main " + customType[i].integer);
}
}
}
and
public class CustomType
{
public static int integer;
public CustomType(int input)
{
integer = input;
System.out.println("CustomType: " + integer);
}
}
I get the following output:
CustomType: 0
CustomType: 1
CustomType: 2
Main 2
Main 2
Main 2
but I want to get this:
CustomType: 0
CustomType: 1
CustomType: 2
Main: 0
Main: 1
Main: 2